in reply to On References to the Unnamed

This generates a list of anonymous scalars:
\@{[]}[0..49]
Taking a reference to a slice yields a reference to each member (it's \ operating on a list). Generating one ref requires the same number of chars as Larry's, and is substantially slower. But if you ever need to generate a substantial list of scalar refs (it catches up at around 20, compared to using map with Larry's), this would be the way to go.

And with all due respect to Larry, here's a golfier way to get a single scalar ref:

\[]->[0]
Now, for the case you mention, in which you merely need a stateless object...well, you don't need an object. You just do everything through class methods. But taking a reference to a constant would work. You don't need an anonymous scalar, because you're not going to modify the contents.

You'd want a scalar when you have an object with only one property. In that case, you'd just declare a lexical scalar in your constructor, and bless a reference to it. So you still don't need anonymous scalars.


Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.