Comment by AnimalMuppet

Comment by AnimalMuppet a day ago

2 replies

Perl is interesting because it was written by a linguist. It's the only language I know of where you can say "it".

Here's what I mean: I'm talking to another developer. I say, "Read in a line of input. If it ends in a newline, remove the newline." I can talk like that to a developer.

But when I talk to a computer, it says, "Read in a line of input? From where? And put it where? If 'it' ends in a newline? If what ends in a newline?" You can't talk to a computer that way...

Except in Perl. In Perl, you say, "Read in a line of input. I didn't specify where, so read in from the standard place[1]. I didn't specify where to put it, either, so put it in the default variable[2]. Then call chomp, which if I don't specify, will operate on the default variable."

[1] The default input is the files specified as command-line arguments, in order.

[2] The default variable, $_, is used when you don't specify a different variable. $_ plays the linguistic role of "it" - it's what you're talking about when you don't specify what you're talking about.

not-so-darkstar 5 hours ago

This is what I'm talking about. Your response made me even more eager to learn it!

dapperdrake 15 hours ago

Doug Hoyte looks at anaphoric macros in his book Let Over Lambda.

Hylang also has thise built in. IIRC it was the anaphoric threading macro "a->".

Apparently this language construct is called an anaphora.