lua-users home
lua-l archive

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


Here is a very cheap solution - for people who for some reason do not
want patches, syntactic sugars, aliases, macro, etcs. I implemented it
in Emacs, because that's what I use; Scite people should be able to
adapt it to Scite in a snap.

If we run this sexp - where "running" means placing the cursor after
the sexp and typing C-x C-e,

  (defun in-env (v e)
    (insert (format "\nlocal %s\ndo local _ENV = %s\n  %s = %s\nend"
		    v e v v)))

then the function in-env becomes defined; if we type this

  -- (in-env "x, y, ..." "expr")

and we run the (in-exp ...) sexp, then in inserts a "local ... do ...
end" block, i.e., the single line above becomes these four lines:

  -- (in-env "x, y, ..." "expr")
  local x, y, ...
  do local _ENV = expr
    x, y, ... = x, y, ...
  end

The rest should be obvious.
  Cheers,
    Eduardo Ochs
    eduardoochs@gmail.com
    http://angg.twu.net/



P.S.:
http://www.gnu.org/software/emacs/manual/html_node/emacs/Lisp-Eval.html

P.P.S.: I am aware that this hack is against the spirit of this list;
I am running for cover. Bye! 8-)


On Sun, Nov 7, 2010 at 12:35 PM, steve donovan
<steve.j.donovan@gmail.com> wrote:
> On Sun, Nov 7, 2010 at 4:26 PM, Gavin Wraith <gavin@wra1th.plus.com> wrote:
>>  local x,y, ... in expr
>
> I'd agree with Gavin - a good candidate for syntactical sugar, since
> it's a common operation with well-defined semantics.  Easier to type
> and read, and encourages use of local aliases. One of those things
> which are hard to macro-ize, since look-ahead is not a strong point of
> the token filter patch.
>
> steve d.
>
>