lua-users home
lua-l archive

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


Mark Hamburg wrote:
[...]
>>From an implementation standpoint, the rule might be that a "do" that
> appears on the same line as the end of a function call defines a function to
> be passed as an extra parameter to the function call. (If one doesn't like
> changing the meaning of "do", then consider using something like "begin".)
> That convoluted specification is intended to support constructs like:
> 
>     profileSection "Section Name" do
>         -- do work to be profiled
>     end

I think what you're basically trying to do is to reinvent Smalltalk-style code
blocks. There's nothing wrong with that --- code blocks are deeply cool things
--- but they don't really fit the way Lua does stuff, so no matter what you do
you're going to end up with a poor fit with traditional code. For example,
your above statement is equivalent to:

profileSection("Section Name", function() ...do work... end)

So, that particular do...end is really a function in disguise. As you point
out, this raises issues because things like return have a different semantic
in code blocks than they do in scopes.

I can't really suggest anything that might help here, other than to write a
full compiler for a non-Lua language with different semantics that targets
Lua. (Something I've been thinking of.)

-- 
╭─┈David Given┈──McQ─╮ "There are two major products that come out of
│┈┈dg@cowlark.com┈┈┈┈│ Berkeley: LSD and Unix. We don't believe this to be
│┈(dg@tao-group.com)┈│ a coincidence." --- Jeremy S. Anderson
╰─┈www.cowlark.com┈──╯

Attachment: signature.asc
Description: OpenPGP digital signature