Setq

Freeform discussion about anything related to modding Transcendence.
Post Reply
george moromisato
Developer
Developer
Posts: 2998
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

I think these two tickets are trying to accomplish the same thing:

http://wiki.neurohack.com/transcendence/trac/ticket/532
http://wiki.neurohack.com/transcendence/trac/ticket/540

Of the two, I prefer the second method:

Code: Select all

(setq
    a  "some value"
    b  "another value"
    c  123
    )
What do you think?
User avatar
Arisaya
Fleet Admiral
Fleet Admiral
Posts: 5535
Joined: Tue Feb 05, 2008 1:10 am
Location: At the VSS Shipyards in the frontier, designing new ships.

The first I think is slightly more convenient from a "getting fancy with coding", given that a lot of things are returned as lists anyways.

For example, you could have a list of items in a station's inventory, and then distribute them to a list of nearby ships.

Its still possible to do it iteratively, but kind of a pain, given some extra lines will be wasted. (and it doesn't take advantage of the latter idea, doing it iteratively)

The latter is more straight forward (setq a 1 b 2 c 3) but has a more limited utility than the above.
(shpOrder gPlayership 'barrelRoll)

<New tutorials, modding resources, and official extension stuff coming to this space soon!>
User avatar
Ttech
Fleet Admiral
Fleet Admiral
Posts: 2767
Joined: Tue Nov 06, 2007 12:03 am
Location: Traveling in the TARDIS
Contact:

It seems to be cleaner, though it seems like something you'd be taking from like like
a=>'value',b=>'value'

But seems good to me. :)
Image
Image
giantcabbage
Militia Lieutenant
Militia Lieutenant
Posts: 107
Joined: Thu Apr 07, 2011 9:05 pm

I would vote for the second method (ticket 540) as a change to setq. In cases where you want to assign multiple variables I find it more readable than the other form.

However, I think 532 is actually asking for something like Python's sequence unpacking where you might write:

Code: Select all

xpos,ypos = get_position(object)
i.e. get_position returns a sequence/list of two values which get unpacked into two separate variables. (It sounds like the common-lisp DESTRUCTURING-BIND macro can do something similar, but I'm not a lisp expert...)

Of course, with 1.07 you could just use a structure instead
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

As I'm not a programmer, I'm not really interested to keep consistency with other dialects of LISP, however the second solution seems easier to me.

I vote for the second method (ticket 540)
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

I think #540 is nice, but it is also sort of what we have in the block local variable definition. That said, it would be a nice addition in itself. #532 is specifically meant to solve returning lists from functions and assigning them to variables right away. So, like giantcabbage said, it is similar to pythons or luas unpacking. I haven't had a chance to really look at structures, but they just might make ticket #532 obsolete.
Get your own Galactic Omni Device
Get it now. It's free!!
Image
Post Reply