5 ms·
I will reference to Steve Yegge's rant on Perl. It has a lot of examples on Perl operators that are overloaded: http://steve.yegge.googlepages.com/ancient-langu
by amix 17y ago
I will reference to Steve Yegge's rant on Perl. It has a lot of examples on Perl operators that are overloaded: http://steve.yegge.googlepages.com/ancient-languages-perl http://steve.yegge.googlepages.com/ancient-languages-perl - - and how their man pages isn't a big help.
While other languages of course have their special syntax, Perl is very extreme in this regard. This is best illustrated by the following diagram of special Perl operators (where most of them are only found and used in Perl):
http://www.ozonehouse.com/mark/blog/code/PeriodicTable.pdf http://www.ozonehouse.com/mark/blog/code/PeriodicTable.pdf
- tomneo 17y agoyou underestimate ur memory mate :P and yegge is wrong. "references" were added to perl because of lexical variables.
- chromatic 17y ago> "references" were added to perl because of lexical variables. I'd like to see a citation for that. My understanding was to allow for simpler nested data structures.
- tomneo 17y agomy mistake ... what i meant to say was lexical variables, lexical closures also needed the concept of references.
- chromatic 17y ago> ... lexical closures also needed the concept of references. I can't imagine how that could be, unless somehow you mean that "first-class functions require references in Perl 5", which is true only insofar as first-class functions rely on the design concept of references. If Larry had invented the idea of a reference context (not the most precise term, but I think it's understandable), references would have been unnecessary in Perl 5.
- tomneo 17y ago> "first-class functions require references in Perl 5" yes thats what i meant. to put it simply. perl4 did not have lexical variables, first class functions, proper syntax for nested data structures. larry said let there be references. its one big hammer to solve all problems. i think perl6 is using a different appoach based on laziness for nested data structures. there are always strings and do blocks which assign and return globs with randomised but unique name(gensym but perls gensym is returns a GLOB reference so you have to write ur own). reference context == continuation right ?? in sub bar { ... $foo = sub { .... } ... return \$foo}, i think \$foo also captures the lexpad of bar using a single reference to $foos internals. thats all. otherwise i think one would need continuations like in ruby or scheme or perl6.
- berntb 17y agoAh yes, Yegge's old rant and the Perl6 (not Perl5!) operator periodic table. Very new on HN! Can you trolls at least get something about Perl5 to post about?! (Answer to a possible answer in advance: "What, you post about another language in the same family -- and claim not to be a troll!?") I'll reference this, regarding language trolling on HN: http://news.ycombinator.com/item?id=963706 http://news.ycombinator.com/item?id=963706 Because I'm just not going to be trolled discussing this on HN, again.
- amix 17y agoYegge's old rant still holds true for both Perl 5 and Perl 6, nothing has changed. There isn't a table of Perl 5 operators - - and the Perl 6 operator table shows what kind of design principles are behind Perl. Anyhow, I wont stay back on the sideline when Perl lovers bashes other languages and spread BS about superiority of Perl.
- berntb 17y ago>>nothing has changed [with Perl 5/6 since 2004] Wow, can you go through the synopses etc and prove that? :-) [Edit: Please put especial emphasis in showing why Moose is bad.] That was sad. Why don't you run along and try to "argue" with someone about Emacs/Vi, instead? Just try to not again start with flaming a language/editor based on a reference to a very different language/editor with a similar name. Also, try to find something better than outdated ranting based on a claim that a humorous speech shows someone is insane... :-)
- thwarted 17y agoOddly, no perl lovers have bashed other languages in this thread, and it would be great if someone could point out that at least one of the things I said were perl, python, ruby, or PHP idioms isn't actually an idiom. So maybe you should stay on the sidelines, since the coach hasn't called you into the game. I do see that PHP is underrepresented in my list, and I just ran across one of PHP's most confusing idioms the other day. The LHS of list expansion assignment requiring the keyword list(), which looks like a function call. I can't count how many experienced programmers have asked me how this assignment to a function call works, which proves this is an idiom. And the opposite is a perl idiom: some functions in perl can operate as lvalues, like substr.
- thwarted 17y agoIt was nice of Yegge to quote the entire section of the perl man pages on how the .. operator works. Notice it is fully documented, all the different contexts it works in, what it returns, how it returns it, the different types it works on. One might consider perl to be OVERLY documented, and navigating the man pages works pretty well when searching from inside less(1). I wish python and ruby and PHP had their entire documentation, or even just a significant standard library function list, available as man pages on every system they are installed on (although, why Ubuntu's doesn't package up perl man pages as part of perl by default, I don't know). Then look up the Ruby documentation for .. , which is also overloaded to have two different meanings, one that works inside conditionals and one that constructs Range objects when outside of Range objects, which is just as much syntactic sugar as anything perl provides. And the difference between .. and ... is visually subtle, I wonder how many off-by-one errors that operator idiom causes.