In
Module Design strawman - Exporter::VA, I’m planning a feature where if the argument is a code ref, it is called immediatly (by the code exploring this structure that is; obviously an undecorated function would be called “immediatly” when
building the data structure) to get the real result. e.g.
fobble => \&figure_it_out.
However, there seems to be a demand for importing by hard link, also. This is easy for other types of symbols, but a contradiction for functions. That is, $x => \$_internal_x is distinguishable from $y => \&generate_y, but if the symbol is itself a function, you can't tell them apart.
Originally I decided to let it mean “call back”, since you can write &foo => sub { \&_hard_link } to get the other case. But can it be simpler/easier?
Well, I think I've got it!
How about, for function symbols, a code ref means “now”, and a ref to a scalar means “later”?
That is,
&foo => \&figure_it_out,
&bar => \\&hard_link
The extra backslash is only one more character, rather than any other form of decorating it which has to surround it and/or involve more words. And, the meaning of backslash is consistant with “take it literally, not special meaning now”.
I think the idea would make a handy idiom for any situation like this, when you're configuring things with code blocks. For example, in user-interface building, Tk has a few forms with various semantics.
Any thoughts?
—John
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.