Buddha Buck:
# My impression was that ~> and <~ were more general than that,
# and mainly
# did syntax-rewriting.
Correct.
# So (4) above was translated in the parsing stage to be
# exactly identical
# to (1), by the following conversions:
#
# # original (4)
# @in ~> map { ... } ~> grep { ... } -> @out;
#
# # Fully Parenthesized
# (((@in ~> map { ... } ) ~> grep { ... } ) -> @out
#
# # "@a ~> function " becomes " function @a
# ((map { ... } @in) ~> grep { ... } ) ~> @out
#
# # @a ~> function ===> function @a
# (grep { ... } (map { ... } @in)) ~> @out
#
# # @a ~> @b ===> @b = @a
# @out = (grep { ... } (map { ... } @in))
#
# # removal of duplicate parenthesis
# @out = grep { ... } map { ... } @in
#
# So the syntax in (1) is still valid.
Incorrect. The translation sequence is:
@in ~> map { ... } ~> grep { ... } ~> @out
((@in ~> map { ... }) ~> grep { ... }) ~> @out
((@in.map({ ... })).grep({ ... })) ~> @out
@out=((@in.map({ ... })).grep({ ... }))
@[EMAIL PROTECTED]({ ... }).grep({ ... })
The only difference between '~>' and '.' is that '~>' is taken as the
terminator of an unparenthesized argument list, while '.' is taken as
binding to the last term.
# With (2) and (3), the situation is different, because they get
# syntax-converted into a different form:
#
# # Original (3)
# @out <~ grep { ... } <~ map { ... } <~ @in;
#
# # fully parenthesized
# @out <- ( grep { ... } <~ ( map { ... } <~ @in));
#
# # function <~ @a ====> function :@a
# @out <- { grep { ... } <- { map { ... } :@in ));
#
# # function <~ @a =====> function :@a
# @out <~ grep { ... } :(map { ... } :@in)
#
# # @a <~ @b =====> @a = @b
# @out = grep { ... } :(map { ... } :@in)
#
# which is horrible, and no one would want to use that directly
# as opposed
# to syntax (1). But I can see beauty in (2) or (3).
#
# Of course, since indirect-object syntax is syntactic sugar
# itself, this
# goes on to be:
#
# # function :@a ===> @a.function, applied repeatedly
# @out = @in.map({...}).grep({...});
#
# which is yet another L2R syntax.
Correct.
# But it also implies that map(&block) and grep(&block) are methods on
# arrays (or Arrays).
Correct again.
--Brent Dax <[EMAIL PROTECTED]>
@roles=map {"Parrot $_"} qw(embedding regexen Configure)
"If you want to propagate an outrageously evil idea, your conclusion
must be brazenly clear, but your proof unintelligible."
--Ayn Rand, explaining how today's philosophies came to be