lua-users home
lua-l archive

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


On Feb 26, 2012 6:14 PM, "HyperHacker" <hyperhacker@gmail.com> wrote:
>
> On Sun, Feb 26, 2012 at 05:46, steve donovan <steve.j.donovan@gmail.com> wrote:
> > On Sun, Feb 26, 2012 at 6:16 AM, Jay Carlson <nop@nop.com> wrote:
> >> But Unix programmers are allergic to backslash being used that way.
> >> Even though my brain says "yes, lots of languages write lambda as
> >> backslash" my eyes say "control character".
> >
> > So \\x(x+1) would read better? ;)

Yes, dammit. I'll have the world's biggest headache with single backslashes.

Which doesn't mean I won't get over it in a week--that's about one wrenching-change-of-neural-rewiring. I once got massive eyestrain from switching video cards (and nothing else) because my eyes had gotten so used to the blurry RAMDAC in the old card.

> > There's also the Go approach, where iterating over a UTF-8 string
> > returns 'runes' rather than the underlying bytes.

I really think Miles is on to something with most iteration being over regexp frontiers and matches.

So in "scripting languages" you get this for two reasons. Everybody expects "sucks less than C" string manipulation or else they'd just write their code in lex or whatever. The second is that "scripting languages" have to have good string primitives in C because iterating over characters is too slow.

This probably was more likely to be true when we were using Tcl or PHP....

Besides, you can always back off to iterating on gmatch".", as long as "." matches what you want....

> >> My favorite lombok-so-bad-it's-good trick is how their implicitly
> >> typed Java "var s = new HashSet()" is syntactically legal.
> >
> > I abuse the helpfulness of Eclipse by writing the same and using the
> > correct feature to quickly fill in the actual type.

Java's lack of mechanism for all kinds of things leads to "just hit Ctrl-1, the IDE will triple the size of your code for you, saving a lot of keystrokes." But this does not save a lot of reading, and I too often get surprised by the one thing I skimmed over as boilerplate which actually wasn't.

Writing {a=a,b=b} and local string,io,os=string,io,os feels the same, although obviously nowhere near as bad. But the constant violation of DontRepeatYourself is an irritant.

> Wouldn't a more Lua-like approach be to use a keyword "lambda" instead
> of a symbol? I think my favourite syntax would be:
> lambda x: x+1

Yes, but the problem we're allegedly trying to solve is that many functional patterns are so bulky to express in Lua that nobody uses them. So the pendulum swings the opposite way, towards terseness, because under this hypothesis the lambda construct for procedure construction is so fundamental it needs short syntax, at least as short as table  construction.

There's a good April Fools' Day joke for you: Lua 5.3 will adopt a keyword style for table construction for clarity.

I don't think anybody is really sure whether this is a good idea or not. Python took the anti-lambda stance; list comprehensions are similar anti-verbosity for iteration without the functional programming baggage.

Jay

Strong authentication just proves which chump is in front of the keyboard.

On Feb 26, 2012 6:14 PM, "HyperHacker" <hyperhacker@gmail.com> wrote:
On Sun, Feb 26, 2012 at 05:46, steve donovan <steve.j.donovan@gmail.com> wrote:
> On Sun, Feb 26, 2012 at 6:16 AM, Jay Carlson <nop@nop.com> wrote:
>> But Unix programmers are allergic to backslash being used that way.
>> Even though my brain says "yes, lots of languages write lambda as
>> backslash" my eyes say "control character".
>
> So \\x(x+1) would read better? ;)
>
>> of describing what I had in mind: string indexing is a partial
>> function from strings to characters.
>
> There's also the Go approach, where iterating over a UTF-8 string
> returns 'runes' rather than the underlying bytes.
>
>> My favorite lombok-so-bad-it's-good trick is how their implicitly
>> typed Java "var s = new HashSet()" is syntactically legal.
>
> I abuse the helpfulness of Eclipse by writing the same and using the
> correct feature to quickly fill in the actual type.
>
>> optional static typing all of a sudden makes dynamic languages much
>> heavier
>
> The approach in Koneki is to encourage people to provide types in the
> @param tags.
>
> steve d.
>

Wouldn't a more Lua-like approach be to use a keyword "lambda" instead
of a symbol? I think my favourite syntax would be:
lambda x: x+1
but that might be difficult to parse, since x:x looks like a function
call, so maybe you'd need a double colon.
lambda x (x+1) -- has the same problem, but even moreso since x(x+1)
is actually a valid statement.

--
Sent from my toaster.