Front page | perl.perl5.porters |
Postings from November 2011
Re: RFC: Autoloading charnames
Thread Previous
|
Thread Next
From:
Tom Christiansen
Date:
November 23, 2011 09:21
Subject:
Re: RFC: Autoloading charnames
Message ID:
6684.1322068823@chthon
Abigail <abigail@abigail.be> wrote
on Wed, 23 Nov 2011 16:26:32 +0100:
>>>> I don't see why using a \N{} sequence should have any impact on what
>>>> functions are available to use in my code.
>>> Compare:
>>>
>>> $ perl -wE 'binmode STDOUT; warn File::Spec->catfile("foo","bar")'
>>> Can't locate object method "catfile" via package "File::Spec" (perhaps you forgot to load "File::Spec"?) at -e line 1.
>>>
>>> with:
>>>
>>> $ perl -wE 'STDOUT->binmode; warn File::Spec->catfile("foo","bar")'
>>> foo/bar at -e line 1.
>> Sure, I think that's confusing too.
> I don't, and I really wish Perl did it more often. Every time I write
> Some::Class::I::did::not::use -> foo ()
> and Perl tells me "oh, you didn't load Some::Class::I::did::not::use",
> I think "well, if you know what's missing, why don't you just do it
> for me". [1]
I've thought that, too. I have a memory-tickle that I even
tried to Make It So, once. Don't remember what came of that.
> But maybe I'm the only Perl user who appreciates DWIM.
*Larry* certainly does: it's a primary motivator behind the spirit of Perl.
Happens all over the place. The only caveat is that you always have to
realize that when Larry says "Do What I Mean", he means it. That is,
it's actually saying "Do What *Larry* Means" — but you are not Larry. :)
(Er, unless you are: Hi, Larry! :):)
> Abigail
>
> [1] I've no idea whether it's actually feasible,
> nor how to do it if it were.
Wouldn't UNIVERSAL::AUTOLOAD suffice to rapid-prototype this?
Seems like that'd be a quick enough way to get a feel for its
effects and side-effects, its benefits and detriments.
--tom
==========================================================
PS: More magical muttering about Perl's dwimmery follow.
+--------------------+
| ᴇx ʟɪʙʀɪs ᴍᴜʀᴀʟɪs: |
+--------------------+
dwimmer
ᴅᴡɪᴍ is an acronym for “Do What I Mean”, the principle that something
should just do what you want it to do without an undue amount of fuss.
A bit of code that does “dwimming” is a “dwimmer”. Dwimming can require
a great deal of behind-the-scenes magic, which (if it doesn’t stay
properly behind the scenes) is called a dweomer instead.
dweomer
An enchantment, illusion, phantasm, or jugglery. Said when Perl’s
magical dwimmer effects don’t do what you expect, but rather seem to
be the product of arcane dweomercraft, sorcery, or wonder-working.
[From Middle English dweomer-cræften, in Laȝamon]
magic
Technically speaking, any extra semantics attached to a variable
such as $!, $0, %ENV, or %SIG, or to any tied variable. Magical
things happen when you diddle those variables.
magical increment
An increment operator that knows how to bump up ᴀsᴄɪɪ alphabetics
as well as numbers.
magical variables
Special variables that have side effects when you access them or assign to
them. For example, in Perl, changing elements of the %ENV array also changes
the corresponding environment variables that subprocesses will use. Reading
the $! variable gives you the current system error number or message.
sigil
A glyph used in magic. Or, for Perl, the symbol in front of a variable name,
such as $, @, and %.
tie
The bond between a magical variable and its implementation class.
ᴡʏsɪᴡʏɢ
What You See Is What You Get. Usually used when something that appears
on the screen matches how it will eventually look, like Perl’s format
declarations. Also used to mean the opposite of magic because everything
works exactly as it appears, as in the three-argument form of open.
And also:
Some human endeavors require a disguise. Sometimes the intent is to
deceive, but more often, the intent is to communicate something true at a
deeper level. For instance, many job interviewers expect you to dress up
in a tie to indicate that you’re seriously interested in fitting in, even
though both of you know you’ll never wear a tie on the job. It’s odd when
you think about it: tying a piece of cloth around your neck can magically
get you a job. In Perl culture, the tie operator plays a similar role: it
lets you create a seemingly normal variable that, behind the disguise, is
actually a full-fledged Perl object that is expected to have an interesting
personality of its own. It’s just an odd bit of magic, like pulling
Bugs Bunny out of a hat.
In his poem "Errantry", Tolkien uses the old word "sigaldry",
which simply means "rune-magic":
| He sat and sang a melody,
| his errantry a tarrying,
| he begged a pretty butterfly,
| that fluttered by to marry him.
| She scorned him and she scoffed at him,
| she laughed at him unpitying,
| so long he studied wizardry,
-> | and sigaldry and smithying.
Clearly, Perl's ᴅᴡɪᴍmer involves sigaldry in its sigil-dweomer. :)
In its Second Edition of 1989, the ᴏᴇᴅ gives only three really old
citations for "sigaldry":
❧ ?c1225 (1200) Ancrene Riwle (Cleo. C.vi) (1972) 155
Sigaldrie [c1230 Corpus sygaldren]. false tollunges leuunge o nore
on swefne & alle wiche-creftes.
❧ a1400 K. Alis. (W.) 7015
Quede and harme he wil me spye,‥Gef he wot of this sygaldrye [Laud
trigoldrye] That this trowes [= trees] kan lye.
❧ ?a1500 Chester Pl., Crucifixion (Shaks. Soc.) II. 69
Burye hym wher thy wil be,
But look thou make no sigaldry
To raise him up agayne.
Tolkien also used sigaldry in Canto VII of his epic poem,
"The Lay of Leithian, whose lines 2068–2079 run:
| Not yet by Men enthralled adored,
| now was he Morgoth’s mightiest lord,
| Master of Wolves, whose shivering howl
| for echoed in the hills, and foul
-> | enchantments and dark sigaldry
| did weave and wield. In glamoury
| that necromancer held his hosts
| of phantoms and of wandering ghosts,
| of misbegotten or spell-wronged
| working his bidding dark and vile
| the werewolves of the Wizard’s Isle.
Somebody should send the ᴏᴇᴅ the Tolkien "sigaldry" citations, being
over four centuries more recent than the few they currently use.
Hm hm hm, maybe we should sneak "sigaldry" into the 4ᵗʰ Edition of
Programming Perl: I'd do believe I'd rather like an ᴏᴇᴅ citation. :)
Seems our existing "dweomer" and "dweomercraft" should suffice.
Gary Gygax and Gene Wolfe also resurrect words otherwise lost to modern use,
even if it's only as a mathom or other bric-à-brac passed around as a curio.
--tom
PS: There, *that* should stoke the googlers after weird old words, even
if my spell-checker does rather hate those spellings. And spells.
Thread Previous
|
Thread Next