4 ms·
>>Perl doesn't have it. It has an imitation. Since perl can't do lists of lists (you have to use what it calls "refs") if I do something like: my $l = map { ($_
by KaeseEs 16y ago
>>Perl doesn't have it. It has an imitation. Since perl can't do lists of lists (you have to use what it calls "refs") if I do something like: my $l = map { ($_ . '', $_ += 0) } @list; I wont get a nice list of pairs but just one flat list. This is a silly limitation to have to think about when you're used to proper high level functional languages.
Well, you won't get a flat list either since you're calling map in a scalar context :) I don't see how the necessity of doing
my @l = map { [$_ . "", $_ + 0] } @list;
rather than
my @l = map { ($_ . "", $_ + 0) } @list;
is a problem with map rather than a problem with Perl's arrays and lists only being able to contain scalars.
- loewenskind 16y agoRats, you caught me before the edit. I thought I got away with it. Perl is actually (unintuitive) a strongly typed language, which is what caught me. >I don't see how the necessity of doing... Because I'm used to being able to have lists of lists and now I have to deal with "refs" everywhere. In creating, in getting the values. The given example doesn't highlight it, but imagine in instead of the simple anonymous function given there the call to map called a function that returns a list? I have to remember to turn that into a "ref" or change the function to look at context and return a "ref" itself. I may not own the function in question. The point is that these are all artificial problems that the programmer shouldn't have to give any thought to. You don't have to in Python. Not in Ruby. Not in Lisp. The only language I have to deal with this kind of limitation I can't think of off the top of my head is C (even C++ can handle lists of lists).
- berntb 16y ago>>The point is that these are all artificial problems that the programmer shouldn't have to give any thought to. Yeah, the references of Perl sucks. Just has to be learned. The Perl feature is that it is flexible. You'll get more library and language capabilities with CPAN than using anything else I know of. The disadvantage is that you have to learn quite a bit of extra stuff. It is the natural language inspiration shining through (not a mathematically elegant and minimal notation, exactly :-). I don't have three languages anymore; just now I only do Perl. This is a choice I made, because it is fun. (I consider going functional again, next. Or, if the Android competition don't work out, maybe Objective C.)
- loewenskind 16y ago>Yeah, the references of Perl sucks. Just has to be learned. But this is part of the larger point: it doesn't have to be learned. Just use something else that doesn't have this frustrating design flaw. >The Perl feature is that it is flexible. As opposed to, say, Lisp? CLOS, the most powerful OO system in existence [1] and it was initially just a library on the language. When people say things like this about perl they're usually talking from '98 or so when perl was the most flexible game in town. A lot has changed since then. >You'll get more library and language capabilities with CPAN than using anything else I know of. Java has more libraries, hands down. I'd say most common programming languages cover every use case that 99% of programmers will encounter, so CPAN/Java libs are only the only hope for a small amount of people in a very small amount of situations. >It is the natural language inspiration shining through You mean the English inspiration shining through. A lot of the ambiguity problems we have in real life (faithfully replicated in perl for us!) are a bigger problem in English than, say, German. >This is a choice I made, because it is fun. To each his own. I would try out some of the more advanced languages though. Lisp has some really cool things like the condition system [2], with Haskell you can easily play with infinite sequences, an incredible type system, etc. >Or, if the Android competition don't work out, maybe Objective C I would advise learning Smalltalk first and playing with that. It's a purer implementation of what you'll be doing with Objective C so it will help you learn good behaviors when you are ready to do some iOS programming. The Smalltalk image is also a fascinating concept. [1] If you disagree, point me to one that is more powerful. And the way I'm judging power is by how many patterns I have to know to use it. In CLOS I don't even have to override a function and then call the base version, I can just use :before/:after methods. [2] This is probably Lisp's nicest feature that hasn't yet been copied by mainstream languages. Which is a shame, software would be a lot more robust if it used this kind of system as opposed to the crippled exception system we use today.
- berntb 16y ago>>[flexible] As opposed to, say, Lisp? Nothing compares to Lisp there, really. Perl is probably closest of the modern ones. But I talked about those I know. CL was a favorite when I studied, but has gone the way of my German and French... I don't know it anymore. :-( Pity it lost out in the market place. Today, CL has too bad library support, afaik. [Edit: I don't know much about the Perl 6 macro system, but it seems harder to use than CL macros. Hard to make it as neat, for a roughly Algol-like language like Perl.] >>CLOS, the most powerful OO system in existence It was more or less copied in Perl's Moose. I wrote "You'll get more library and language capabilities with CPAN than using anything else I know of." And got the counter example "Java". Afaik, you don't get language extensions like a new OO system in Java...? So after comparing with CL for flexibility -- you compare amount of libraries with a system language, with roughly half the development speed (and a lot more pain) compared to scripting languages and Lisp...? >>You mean the English inspiration shining through. Oh, please... that was irrelevant bashing. I take your point re Smalltalk, I've only read about the language. Edit: Fixed syntax, clarity.