lua-users home
lua-l archive

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



I wouldn't remember this, but I like the |name| syntax, it sort of makes the variables stand out of the crowd. The only trouble would be, any string is subject to this analysis then? I'll think about it.

Thanks to John, too, the 2 pages on the wiki are impressive as such.

-asko

On Mon, 09 Oct 2006 11:54:18 +0100
 Daniel Silverstone <dsilvers@digital-scurf.org> wrote:
On Mon, 2006-10-09 at 12:02 +0300, askok@dnainternet.net wrote:
Opinions, am I getting completely nuts?
[snip]

Well, you already were nuts, but Aranha does have something similar to this as you may recall from my presentation at the conference.

Aranha has:

some string with |value|s interpolated into it.<<

Where things in | markers are considered as expressions and parsed as
such in Lua's parser.

That above string gets parsed by Aranha as

__divertedstring("some string with %ss interpolated into it.", value)

But you get to have a lot more fun when you do things like

Hello |name|. You are |myage - yourage #d| years younger than I am.<<

which is *parsed* as:

__divertedstring("Hello %s. You are %d years younger than I am.", name,
myage - yourage)

Thusly allowing arbitrary expressions to be interpolated.

It wouldn't be a massive thing to do to extract this bit of Aranha's functionality and alter it to be something slightly more generic for Lua
proper.

D.

--
Daniel Silverstone http://www.digital-scurf.org/ PGP mail accepted and encouraged. Key Id: 2BC8 4016 2068 7895