Godot: move along

Created on 29 Jan 2016  路  30Comments  路  Source: godotengine/godot

nope

archived

All 30 comments

Related to #2966

I will add 2.1 label since for 2.1 there are planned works on new version of gdscript (or possibly another language with strong typing).

python does this stuff with touples, while gdscript does not support touples. I guess this could be added as syntax sugar though

problem is, python an do something like

a,b=b,a

to swap values, for example, should consider it too

From @Dillybob92 in #4863:


I was looking over one of my gdscripts earlier today and thought of this

var client = null
var wrapped_client = null
var GlobalScene
var GamePlayer
var GamePlayer2
var Live_Skills = {}
var GO = {"GAME_VERSION":"1.0.1", "volume":0.15, "CAMERASPEED":7}
var ChatMessages = []
var GameChatMessages = []
var tGameMessages = {}
var user = {"muffin": 1}
var players = {}
var Skills = {}
var Items = {}

Could be:

var client = null, wrapped_client = null,
    GlobalScene, GamePlayer, GamePlayer2,
    Live_Skills = {}, GO = {"GAME_VERSION":"1.0.1", "volume":0.15, "CAMERASPEED":7},
    ChatMessages = [], GameChatMessages = [], tGameMessages = {},
    user = {"muffin": 1}, players = {}, Skills = {},
    Items = {}

I think if 2.1 included this, it would be a nice aesthetic feature. I know it's a personal preference and some devs don't like this, but figured I'd throw this idea out there :8ball:

Aww I guess Reduz does know :D So up to him, probably a lot other important stuff for 2.1 ++, but thanks @vnen, didn't see this thread :)

holy shit @vnen s memory is next level

It'll be great to have CSV

In Pascal or in Nim language like so:

    a = 1
    b = 1.0
    c = "Hello"

It might be a bit nicer to read.

I'd love if we're able to do this

var a,b,c,d=1,2,3,4
a,b,c,d=1,2,3,4
var a,b,c,d={1,2,3,4}

Something like that would be much more useful.

I want to see a real usecase though, I just think it would make oneliners more prominent :(

Well such sugar is not particularly useful.

What is useful, however, is:

var a = 1
var b = 2
var c = 3
var a, b, c = c, a, b
print(a, b, c)  # 3, 1, 2

But that's not trivial to implement.

And of course if the above syntax is supported, then multiple assignment to literals should be supported too, so the above could be:

var a, b, c = 1, 2, 3
var a, b, c = c, a, b
print(a, b, c)  # 3, 1, 2

@akien-mga that's precisely what I had in mind

In fact
var a = 1
var b = 2
var a,b = b, a <<< SUPER SUPER useful
or a,b = b,a
swapping variables is such a common thing in every program

Ok, let's say I agree that it is useful, even though the implementation would be tricky. :smiley:

Oh, the other thread was a duplicate.

Anyway, I could look into how I could implement this with help of the pattern matcher. The lazy approach would just reuse the pattern syntax but that's not very pythonic... I guess I'll play around with it a little bit

@vnev var GlobalScene, GamePlayer, GamePlayer2, Live_Skills = {} would lead to problems.
This might be a better way to write it var GlobalScene = GamePlayer = GamePlayer2 = Live_Skills = {}
Or if your goal was multiple {} then this is more understandable: var GlobalScene, GamePlayer, GamePlayer2, Live_Skills = {}, {}, {}, {}

@ClikCode I was just citing @Dillybob92. And for the sample code, I believe the proposal meant that GlobalScene, GamePlayer and GamePlayer2 would be undefined in the line var GlobalScene, GamePlayer, GamePlayer2, Live_Skills = {}. Only the last one would get a value.

I don't have a personal opinion on this subject.

@vnen To my trained pythonic eyes, that code looked like a syntax error. It's not a problem with you or anyone. I just want the code to be readable.

var {
    X=1
    A=2
    B=3
}

How about this? Reuse the ruby-like dictionary.

@ClikCode a b c = 1 2 3 would be more useful so if you really want it that way maybe
var { a b c } = { 1 2 3 }

@trollworkout that could be done with lists var [a, b, c] = [1, 2, 3] I think keep curly brackets for dictionaries. It could also be done without brackets. var a, b, c = 1, 2, 3

@ClikCode You can even omit the comma. You understand why this is a good idea right?

a =1, b = 2, c = 3
var a b c = 1 2 3

a = 1, b = a, c = b
var a b c = 1 a b

a = 1, b = a, c = (null)
var a b c = 1 a

a = null, b = (null), c = (null)
var a b c = null

create a quick variable swap in a function
a b = b a

Reduces the amount of typing for example only one = equal symbol is necessary and adds the ability to quickly assign one variable value to another.

of course this can be written in so many ways i just find this particular way most useful because no comma only 1 equal and only 1 var

@trollworkout Let s try writing without any commas periods and other punctuation marks whatsoever ok I find this type of listing items variables topics or just things particularly disgusting myself

Here is the above with the "other punctuation marks" back in:

@trollworkout Let's try writing without any commas, periods, and other punctuation marks whatsoever, ok? I find this type of listing items, variables, topics or just things particularly disgusting myself.

how about we don't even bother about it anymore

if you guys not willing to discuss and just willing to disagree or find things i say "disgusting" let's agree to not even bother about it and not even implement it. sounds like a much better approach. why even debate. i suggest we revert to name calling next.

Well Bojidar's word might have been a bit strong, but he was just saying he considers your proposal to chain variable declaration with no separator a bad idea, opinion that I share. There is still interest in having the possibility to declare multiple variable at the same time, but the syntax it should have has to be consensual. Unpacking 脿 la Python with a, b = 1, 2 would be nice, but a syntax like a b = 1 2 is just weird and (AFAIK) unprecedented. If no language in the world uses it, there is likely a good reason, and it's good enough for us not to want to consider it.

Now, thanks for killing this issue that we had taken as reference for other similar requests... I guess I'll just reopen the most relevant one.

@akien-mga Please open another issue have your discussion without me because obviously i'm not needed, wanted or invited. That is my ideas are too "disgusting" for you.

@trollworkout I'm sorry if you think that I think that your whole proposal is bad (double-read the last sentence, just in case). What I meant is that punctuation marks are there for a reason, and I find it hard to understand others without those. I'm not against a, b = 1, 2 and some of the other ideas expressed above.

Finally, if you find my previous comment too terrible to bear, I would gladly remove it and reapologise for it.

troll is being immature. boji had acted immature as well. but troll,
you are trolling. if you over react like that you really need to go
see a therapist. we are all trying to get along and work on this
amazing project

On 29/01/2017, Bojidar Marinov notifications@github.com wrote:

@trollworkout I'm sorry if you think that I think that your whole proposal
is bad (double-read the last sentence, just in case). What I meant is that
punctuation marks are there for a reason, and I find it hard to understand
others without those. I'm not against a, b = 1, 2 and some of the other
ideas expressed above.

Finally, if you find my comment too terrible to bear, I would gladly remove
it and reapologise for it.

--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
https://github.com/godotengine/godot/issues/3504#issuecomment-275939962

Ok let's stop trying to make each other's diagnostic, case closed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RebelliousX picture RebelliousX  路  3Comments

bojidar-bg picture bojidar-bg  路  3Comments

gonzo191 picture gonzo191  路  3Comments

SleepProgger picture SleepProgger  路  3Comments

Zylann picture Zylann  路  3Comments