cdumont writes: > there are some changes in the grammar which benefits aren't that > obvious :
Hi there. For some of these the benefit is indirect: it isn't that it makes the feature in question easier to use; instead it enables _other_ features. > 1- $str1 ~ $str2 > I do not really understand the new concatenation style when most of > the time it's '+' or '.' It isn't great, but I'm sure we can live with it. It frees up dot for other things. Anyway, because of interpolation Perl doesn't use concatenation as much as many other langauges (and even less so in Perl 6 with method calls being interpolatable and braces for conveniently interpolating any code at all). It also has the advantage that tilde is consistently used in several places in Perl 6 to indicate strings. > 2- $life = (!$monster) ?? 'safe' !! 'dead'; > I don't see how putting 2 questions marks and 2 exclamations marks > make things shorter and easier to understand. Clearly it doesn't -- but then I don't think anybody is claiming that that's the reason for the change! Shortness isn't always a virtue; by using doubled characters they stand out more, which makes it easier to spot when this operator is being used -- something that's more important with this operator than most, since it is split between two positions. And it frees up some symbols for use in other operators. > 3- given $operator { > when '' {} > } > > > The given ... when doesn't seem to bring that much from switch ... > case given ... Surely it brings all of it? Plus much more as well. Much of the power is in the smart-matching, which enables many different sorts of comparisions, each naturally matching the appropriate thing. A big advantage given has over C's switch construct is not having to include break in the usual case (and get mysterious-yet-silent bugs if you accidentally forget it). > And hashes require '=>' but it could be nice to switch to ':' Indeed it could be. But, unfortunately, the colon seemed to be top of many people's most-wanted lists, with many different (and mutex) suggestions for what it should do. (Remember, only a couple of paragraphs ago you were wanting to keep it for the ? ... : operator!) Possibly somebody could design a language in which the colon is the only symbol used ... > because then :(or perhaps we can use whatever separator we want?) > > { > elems : { > deleting : { > ids : [1,2,3], > names : ['concatenation','ternary operator','switch'] > }, > replace : { > with : ['.','?:','switch...case'] > } > }; > And I know this may not sound that much but it could be sent to > javascript or actionscript or any ecmascript based languages. The key bit of the above is your parentical comment about using whatever separator you want -- which is exactly what Perl 6 provides the flexibility to do. In Perl 6 it will be possible to do: use Grammar::JSON; and then within that file you can have the above syntax for complex data-structures. Or at least, it will if somebody writes the Grammar::JSON module -- but the whole point of Perl 6's pluggable grammars is that it specifically supports people who want to do this sort of thing: it recognizes that not everybody is going to agree on the ideal syntax, so instead it merely provides a 'default' syntax (which Larry judges to be the best all-round) then provides a way of changing anything about it. Hope that helps. Smylers