[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Some crazy proposals :-)
- From: Sean Conner <sean@...>
- Date: Fri, 10 Jul 2015 00:54:48 -0400
It was thus said that the Great Egor Skriptunoff once stated:
> The following "proposals" are just for fun.
> 3) Labels are considered to be first-class citizens
> local my_label = Label1 -- assigning a value of type "label" to a variable
> -- Now "goto" operator gets its real power!
> goto my_array_of_labels[where_do_you_want_to_go_today]
> -- And of course the same is true for "comefrom" :-)
> comefrom get_some_labels()
> -- it is equivalent to "comefrom label1, label2,..."
> -- where label1, label2,.. are values returned by LAST invocation of
> -- "comefrom" without labels is valid (it just does nothing useful)
That's not crazy.
Allowing labels to be nonunique is getting there.
local x = 1
local y = 2
local x = 3
local y = 4
local x = 5
local y = 6
Going to such a label will pick one at random. Now you're going
-- now, what is x? Muahahahahahah!
Allowing a patten for "Name", picking a label that matches at random, that
goto .* -- Where did he go?
And lest you think I'm making this up, nope. There does exist a language
out there that does this very thing. A commercial application was even
written in it. It was quite an insane program, to be truthful.
> 4) Program can modify its own body using methods of labels
> A label is a "bookmark" between statements in a program (or before first
> statement or after last statement)
> A label may be named (defined at compile time) or unnamed (created at
> -- standard library function to create unnamed label just before current
> local here = labels.this_label()
> -- create label just before some_func invocation
> local previous_some_func_invocation = here:search_nearest("backward",
> "call", "some_func")
> -- replace "some_func()" with "another_func()" in the program body
> -- go to unnamed label
> goto previous_some_func_invocation
We have multiple exit points in a function in Lua. Why not multiple entry
points into a function in Lua? This is easily done in Assembly.
-spc (I'll pick "Insane Language Ideas" for $600, Alex)