Nameless labels?

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Nameless labels?

Soni "They/Them" L.
Why doesn't Lua have nameless labels or something?

Would look somewhat like this:
     local s = "start"
     ::@::
     print s
     if s == "restart" then
         goto +
     end
     if s == "start" then
         s = "restart"
         goto -
     end
     ::@::
     print "end"

Reply | Threaded
Open this post in threaded view
|

Re: Nameless labels?

Rena

On 2014-01-11 12:58 PM, "Thiago L." <[hidden email]> wrote:
>
> Why doesn't Lua have nameless labels or something?
>
> Would look somewhat like this:
>     local s = "start"
>     ::@::
>     print s
>     if s == "restart" then
>         goto +
>     end
>     if s == "start" then
>         s = "restart"
>         goto -
>     end
>     ::@::
>     print "end"
>

Because that looks hideous. This isn't assembly.

Reply | Threaded
Open this post in threaded view
|

Re: Nameless labels?

Kaj Eijlers
Hmmm, is this a common idiom? I must have programmed in 20 or so languages and have never seen this, so am not surprised that Lua doesn't support it.

Also, it doesn't exactly improve readability.

As an aside, assembly is pretty elegant Rena, it's just low level but it's pretty straightforward to read and hardly ever confusing unless done intentional.


On Sat, Jan 11, 2014 at 9:59 AM, Rena <[hidden email]> wrote:

On 2014-01-11 12:58 PM, "Thiago L." <[hidden email]> wrote:
>
> Why doesn't Lua have nameless labels or something?
>
> Would look somewhat like this:
>     local s = "start"
>     ::@::
>     print s
>     if s == "restart" then
>         goto +
>     end
>     if s == "start" then
>         s = "restart"
>         goto -
>     end
>     ::@::
>     print "end"
>

Because that looks hideous. This isn't assembly.


Reply | Threaded
Open this post in threaded view
|

Re: Nameless labels?

Soni "They/Them" L.
I've seen it in assembly... I think it would be great for continues...

On 11/01/2014 16:12, Kaj Eijlers wrote:

> Hmmm, is this a common idiom? I must have programmed in 20 or so
> languages and have never seen this, so am not surprised that Lua
> doesn't support it.
>
> Also, it doesn't exactly improve readability.
>
> As an aside, assembly is pretty elegant Rena, it's just low level but
> it's pretty straightforward to read and hardly ever confusing unless
> done intentional.
>
>
> On Sat, Jan 11, 2014 at 9:59 AM, Rena <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     On 2014-01-11 12:58 PM, "Thiago L." <[hidden email]
>     <mailto:[hidden email]>> wrote:
>     >
>     > Why doesn't Lua have nameless labels or something?
>     >
>     > Would look somewhat like this:
>     >     local s = "start"
>     >     ::@::
>     >     print s
>     >     if s == "restart" then
>     >         goto +
>     >     end
>     >     if s == "start" then
>     >         s = "restart"
>     >         goto -
>     >     end
>     >     ::@::
>     >     print "end"
>     >
>
>     Because that looks hideous. This isn't assembly.
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Nameless labels?

Rena
In reply to this post by Kaj Eijlers

On 2014-01-11 1:13 PM, "Kaj Eijlers" <[hidden email]> wrote:
>
> Hmmm, is this a common idiom? I must have programmed in 20 or so languages and have never seen this, so am not surprised that Lua doesn't support it.
>
> Also, it doesn't exactly improve readability.
>
> As an aside, assembly is pretty elegant Rena, it's just low level but it's pretty straightforward to read and hardly ever confusing unless done intentional.
>
True. I've just never seen this outside of assembly.

(btw, top posting is frowned upon.)

Reply | Threaded
Open this post in threaded view
|

Re: Nameless labels?

Coda Highland
In reply to this post by Soni "They/Them" L.
On Sat, Jan 11, 2014 at 10:38 AM, Thiago L. <[hidden email]> wrote:
>> Why doesn't Lua have nameless labels or something?
> I've seen it in assembly... I think it would be great for continues...

Lua has something better than nameless labels -- it has SCOPED labels.
A label is only visible within the block containing it. This allows
you to use the same label (e.g. ::continue::) in every circumstance in
which you need it.

/s/ Adam

Reply | Threaded
Open this post in threaded view
|

Re: Nameless labels?

Kaj Eijlers
Whoops, sorry about the top post - gmail conveniently hides it.

Never seen it in assembly, maybe I got too late to the assembly game (around 1982), all assemblers I have used had proper labels (or maybe they supported it but noone I interacted with used them - thank God!)
Anyhow, I prefer labels to be named according to their function in the loop because even I who has advocated goto usage in C for a long time in the workplace find them pretty much unneeded nowadays and obscuring flow.

Reply | Threaded
Open this post in threaded view
|

Re: Nameless labels?

Andres Perera
On Sat, Jan 11, 2014 at 2:33 PM, Kaj Eijlers <[hidden email]> wrote:
> Whoops, sorry about the top post - gmail conveniently hides it.
>
> Never seen it in assembly, maybe I got too late to the assembly game (around
> 1982), all assemblers I have used had proper labels (or maybe they supported
> it but noone I interacted with used them - thank God!)

op is describing two things: syntax relative jumps and nameless
labels, with little correlation between the two

the former you have in gas[0], eg jmp 1f to jump to the nearest label
named 1 doing a forward transversal

0: http://tigcc.ticalc.org/doc/gnuasm.html#SEC48

> Anyhow, I prefer labels to be named according to their function in the loop
> because even I who has advocated goto usage in C for a long time in the
> workplace find them pretty much unneeded nowadays and obscuring flow.
>

Reply | Threaded
Open this post in threaded view
|

Re: Nameless labels?

Andres Perera
On Sun, Jan 12, 2014 at 2:34 AM, Andres Perera <[hidden email]> wrote:

> On Sat, Jan 11, 2014 at 2:33 PM, Kaj Eijlers <[hidden email]> wrote:
>> Whoops, sorry about the top post - gmail conveniently hides it.
>>
>> Never seen it in assembly, maybe I got too late to the assembly game (around
>> 1982), all assemblers I have used had proper labels (or maybe they supported
>> it but noone I interacted with used them - thank God!)
>
> op is describing two things: syntax relative jumps and nameless
> labels, with little correlation between the two
>
> the former you have in gas[0], eg jmp 1f to jump to the nearest label
> named 1 doing a forward transversal
>
> 0: http://tigcc.ticalc.org/doc/gnuasm.html#SEC48

furthermore,

* lua alleviates namespace exhaustion by having block scoped labels;

* having unnamed labels has demonstrably no impact when paired with
syntax-rel jumps, making reusable names that the parser turns into
block-unique the real issue;

-- named
x = 0
::a::
x = x + 1
if (x == 4) goto + end
goto -
::b::

-- unnamend
x = 0
::@::
x = x + 1
if (x == 5) goto + end
goto -
::@::

>
>> Anyhow, I prefer labels to be named according to their function in the loop
>> because even I who has advocated goto usage in C for a long time in the
>> workplace find them pretty much unneeded nowadays and obscuring flow.
>>