lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


It was thus said that the Great Egor Skriptunoff once stated:
> Hi!
> 
> The following "proposals" are just for fun.
> 
> 3) Labels are considered to be first-class citizens
> 
> ::Label1::
> ...
> 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
> get_some_labels()
> -- "comefrom" without labels is valid (it just does nothing useful)
> ...

  That's not crazy.

  Allowing labels to be nonunique is getting there.

	::foo::
	local x = 1
	local y = 2
	goto bar

	::foo::

	local x = 3
	local y = 4
	goto bar

	::foo::

	local x = 5
	local y = 6

	::bar::

  Going to such a label will pick one at random.  Now you're going
somewhere.

	goto foo
	-- now, what is x? Muahahahahahah!

  Allowing a patten for "Name", picking a label that matches at random, that
is craziness.

	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
> runtime)
> 
> ...
> some_func(some_params)
> ...
> -- standard library function to create unnamed label just before current
> statement
> 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
> previous_some_func_invocation:replace_statement("another_func()")
> ...
> -- 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)