Is "item context" what we're calling scalar these days, or something else?

On 6/3/07, Jonathan Lang <[EMAIL PROTECTED]> wrote:
Chas Owens wrote:
> I am almost certain that the following code is in list context.
>
> pugs> my @a = '-' x 5, 'foo', '-' x 5;
> pugs> @a
> ("-----", "foo", "-----")
> pugs> my @b = cat('-' xx 5), 'foo', cat('-' xx 5)
> ("-", "-", "-", "-", "-", "foo", "-", "-", "-", "-", "-")
>
> However, it does seem that Pug's version of cat does not handle the
> Str emulation, so that may fix it, but I don't see how it could since
> (at least in my mind) the code above is in list context.

You're right; it is.

From what you're saying, I get the impression that you think that "'-'
x 5" ought to produce a single string of five dashes regardless of
whether the context is item or list.  Correct?  (Note: I'm not asking
about what the spec says, since what it says is potentially up for
revision, given sufficient cause; I'm asking about what you think the
spec _should_ say.)  If so, "cat($n xx *)" is not an adequate
replacement for "$n x *", since it produces a list of one-character
strings if used in list context.  OTOH, "~cat($n xx *)" might work.

Personally, I would tend to favor the notion that infix:<x> always
produces a single string.  With this in mind, I'm now leaning toward
"~cat($a xx $n)" as the more verbose equivalent of "$a x $n".  You
always produce a single string, and you do so lazily (according to the
way that 'cat' works in item context).

--
Jonathan "Dataweaver" Lang



--
Mark J. Reed <[EMAIL PROTECTED]>

Reply via email to