On Wednesday, January 22, 2003, at 07:40  PM, Thomas A. Boyer wrote:
I have a strong suspicion that this possibility was carefully considered by {LW, DC, ...} (that's set notation, not a code block :) before the Apocalypse 4 "pointy sub" syntax (and the for-loop syntax using it) was promulgated. And that it was
Yes, no doubt so, and good point. I think I should make it clear that my speculation on somehow unifying C<for> and C<map> is _not_ an attempt to gut A4, because I like A4 quite a lot. I'm just thinking out loud about how we could _extend_ A4 in one particular way.

I keep thinking there has to be a way to extend the pointy sub syntax to just *do* the kind of piping we keep talking about. I like the <~ and ~> proposal, but it's true that they imply a symmetry that isn't really there. I like pointy sub, but it's true it's a win only in limited circumstances.

Think, think. What do these things have in common?

# known from A4

for @a, sub ($x) {...} # primitive spelling
for @a -> $x {...} # pointy sub, looks great

map {...} @a # old-style map syntax
map sub ($x) {...}, @a # primitive spelling
map -> $x {...} @a # pointy sub? Oof, kinda opaque, here.

# purely speculative alternatives

for @a : sub ($x) {...} # indirect object syntax
for @a : -> ($x) {...} # not as good as before

map @a : {...} # indirect object syntax
@a -> map {...} # L2R
map {...} <- @a # R2L (these look great)

# But the combination of both meanings doesn't work at all.
# (pointy sub doesn't work as well with indirect-object or
# pipe-like syntax, and vice versa)

map @a : -> $x {...} # indirect + pointy sub
map @a : sub ($x) {...} # arguably better looking?

@a -> map sub ($x) {...} # objpipe + primitive spelling (OK)
@a -> map -> ($x) {...} # objpipe + pointy sub (very NOT OK)
@a -> map ($x) {...} # 'implied' sub? (Nope, NOT OK)

I mean, it _looks_ like there should be way to put those together by making '->' mean something more encompassing than pointy sub. There's some beautifully expressive syntax in there.

Think, think...

MikeL



Reply via email to