in reply to Re: A Romp Around addn
in thread A Romp Around addn
Perl 6 doesn't have to be terse. Even moreso than in Perl 5, you can for example name the variables instead of using $_.
—John
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: A Romp Around addn
by jethro (Monsignor) on Aug 18, 2008 at 18:22 UTC | |
So the APL library on cpan6 is not far away and all those old financial programs not written in COBOL will be moved over from ancient mainframes to perl. Hooray ;-) Terseness is not a problem in itself. No one likes to type 'System.out.println' instead of 'print' (one of the reasons I never got around programming in java). The problems begin when the redundancy is so low and the feature density so high that you can replace or add one single punctuation character or even a space and the statement is with high probability still syntactically correct and does something totally different. perl already has a reputation as a obfuscated language, this reputation might even get worse with perl6. I've gotten a lot better reading perl code since I've started posting here on perlmonks, but I still get the uneasy feeling occassionaly that the bug I identified in some users code might be valid syntax that I just forgot. Just a few days ago I saw that someone had typed =\ instead of =~ in his code. To my surprise the whole statement was still valid syntax but I couldn't say why at first. With the explosion of (syntactically) overloaded/reused punctuation characters in perl6 I fear I might get that surprise a lot more often Don't get me wrong, I like perl6 and the freedom of picking all the bits I like out of the language will make me a happy coder. And my fears are probably based on ignorance and an overdose of apocalypses read a long time ago. But my impression was that perl6 syntax has twice or three times as many constructs/elements as perl5 and instead of using words to make those constructs easily distinguishable, another layer of meaning is heaped upon some punctuation character. brackets have 4 uses in perl5 depending on context, caret three and colons two. In perl6 each has a lot more (if my impression is correct). Apart from the poor people who have to write the perl6 parser what about the humans who have to parse it? | [reply] |
by John M. Dlugosz (Monsignor) on Aug 19, 2008 at 05:46 UTC | |
Looking at why the Perl was even shorter than the Lisp: not needing delimiters does not change the number of function points or size of the parse tree, just makes it easier to type. And still declaring parameters but not having to list them all at the top as well saves effort but does not eliminate the information from the source code. In Perl 6, there are indeed more meanings, but the symbols are used more consistently and uniformly. In my article, you saw how ^$n was clearly related to 0..^$n so it registers mentally as an abbreviation, even though it concerns different operators. And the use of the caret there is obliquely related to the anchor in a regex, conceptually. Backwards, but it makes me think "relates to the endpoint", or in a character range it means "exclude". The colon character does have a few totally different uses, but they are familiar and unconfusing: statement labels, package namespace, etc. The new use of :( ) as the delimiter for a signature is kind of arbitrary, but it makes qualified (overloaded) function names read well, and still using parens rather than some new bracket makes parameter list declarations familiar, with the : optional where a signature but not an expression is expected. A lot of milage comes from its use in "pair" syntax, but that is one use. It is pairs that have many uses, in hash items, named parameter passing, flags, etc. So, I think that learning the meanings systemattically rather than just picking them up one at a time would enable you to better see the organization behind it. ? means boolean/bistate/optional, + means numeric, ~ means string. So $x? is an optional parameter, just as it means 0-or-1 occurances in a regex, and ?| is a boolean "or" as distinguished from +| which is a bitwise "or", and ? as a prefix converts to Bool and imposes boolean context. So, you can guess what infix ?& means, right? You might not guess what $obj.?foo() does, but the use of the symbolism is clear once you are told, and you won't forget. It optionally calls the method, if it exists on the object, but is not an error if it doesn't exist. —John | [reply] [d/l] [select] |