Re: iteration (was Re: Angle quotes and pointy brackets)
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Matt Diephouse) wrote: >On Sat, 04 Dec 2004 08:59:24 -0700, David Green <[EMAIL PROTECTED]> wrote: >C signifies a role named "Iterate". Roles are sort of a >mix of interfaces and mixins (as I understand it -- I'm still waiting >for E12). So saying a class fulfills a role just means that it >provides certain methods. In this case, I was saying class with the >Iterate role would provide a C<.next> method. I thought of that at first, but I don't want to have to call my iterating method "next" any more than I want to *have* to call my constructor "new". But there is a difference in that "new" is called by some user who is supposed to have read the documentation, whereas "next" needs to get implicitly called by "for". So maybe it really should be a Role. (One can always provide methods with better names that simply call the "real" .next, .prev, .final, etc. for increased user-friendliness.) &eof := &final;# is that how to create an alias for a sub/method? > >We've got "while" for looping, ".next" for iterating, > > and "for" for doing both in one convenient little shortcut. > >But for needs to know if it has an iterator or a list. You don't want >it iterating over things you didn't want it iterating. In this case, I >was suggesting making an, though I suppose something like >C<$sth.execute> could just return one. Well, I was looking at lists as being kinds of iterators. If you want to "for" over an iterator without actually iterating it, I guess you'd have to make a reference to it or put it inside a list (so the list would be iterated instead). - David "iterate: to go around and around, like my head" Green
Re: Angle quotes and pointy brackets
On Thursday, December 2, 2004, 10:08:31 AM, you (mailto:[EMAIL PROTECTED]) wrote: > On Tue, 30 Nov 2004, Austin Hastings wrote: >> How about just having C< system() > return a clever object with .output and >> .err methods? > interesting... > Michele Prior art of this on Windows... http://msdn.microsoft.com/library/en-us/script56/html/wslrfExecMethod.asp (the respective properties on the returned WshScriptExec instance being .StdOut and .StdErr.) -- Richard mailto:[EMAIL PROTECTED]
Re: iteration (was Re: Angle quotes and pointy brackets)
David Green <[EMAIL PROTECTED]> wrote: > Aren't lazy lists a funny kind of iterator? Ones that memoise their > results. And supply an indexing method []. As I mentioned the other day, I fail to see any material difference between an iterator and a lazy list, except that a few operations are allowed on a lazy list that aren't on an iterator. (And all of those could be emulated, albeit inefficiently, with one; even with a pipe, if the user does $pipe[1024], there's no technical reason you can't store the first thousand-odd lines and return the one they asked for.) Also note that there's no difference between iterating over a lazy copy of an array, and iterating over a lazy copy of a lazy copy of an array, except for the amount of indirection; thus, there would be no need for for() to distinguish between C and C (though both of those forms might need a splat). -- Brent 'Dax' Royal-Gordon <[EMAIL PROTECTED]> Perl and Parrot hacker "I might be an idiot, but not a stupid one." --c.l.p.misc (name omitted to protect the foolish)
Re: iteration (was Re: Angle quotes and pointy brackets)
On Sat, 04 Dec 2004 08:59:24 -0700, David Green <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] (Matt Diephouse) wrote: > >Supposing > >class Filehandle does Iterate; # Iterate or Iterator? > >we have an easy way to create new iterators. I'm not sure how useful > >they would be in Perl 6 > > Maybe the class doesn't do it, but one of its methods does? Then you > can call it whatever makes sense. C signifies a role named "Iterate". Roles are sort of a mix of interfaces and mixins (as I understand it -- I'm still waiting for E12). So saying a class fulfills a role just means that it provides certain methods. In this case, I was saying class with the Iterate role would provide a C<.next> method. > >Which be even cuter like this (I think): > >for iter($sth.execute) -> $results { ... } > >where iter creates an Iterator object that just knows to call C<.next> > >on its argument. > > That still seems too cumbersome to me. Isn't it "for" that knows to > call .next (or .sequel, whatever)? I'm thinking that that is the > point of "for $foo", which should be approximately the same as "while > $foo.next". We've got "while" for looping, ".next" for iterating, > and "for" for doing both in one convenient little shortcut. But for needs to know if it has an iterator or a list. You don't want it iterating over things you didn't want it iterating. In this case, I was suggesting making an, though I suppose something like C<$sth.execute> could just return one. > >Hoping I haven't removed all doubt of my foolishness, > > I'm hoping this reply reassures you. Thanks. -- matt diephouse http://matt.diephouse.com
Re: iteration (was Re: Angle quotes and pointy brackets)
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Matt Diephouse) wrote: >What I mean is that Perl takes an array and makes an iterator out of it. >Sure, you probably don't think about it like that, but the behavior is >the same (who says arrays need to iterate starting at element zero?). I probably didn't, but over the last couple of days I've been thinking about it like that more and more. >The odd thing is that here we are designing Perl 6, and we're trying >to take an iterator and make it into an array so that we can turn it >back into an iterator again. It seems like we should just use it as an >iterator:: >for $iterator -> $elem { ... } Yes! >Supposing >class Filehandle does Iterate; # Iterate or Iterator? >we have an easy way to create new iterators. I'm not sure how useful >they would be in Perl 6 Maybe the class doesn't do it, but one of its methods does? Then you can call it whatever makes sense. class Filehandle { method next is iterator {...} } class Monarch { method succeed is iterator {} } class Blockbuster { method sequel is iterator { $.title++; return $self; } } >(how do iterators compare to lazy lists?) Aren't lazy lists a funny kind of iterator? Ones that memoise their results. And supply an indexing method []. >Which be even cuter like this (I think): >for iter($sth.execute) -> $results { ... } >where iter creates an Iterator object that just knows to call C<.next> >on its argument. That still seems too cumbersome to me. Isn't it "for" that knows to call .next (or .sequel, whatever)? I'm thinking that that is the point of "for $foo", which should be approximately the same as "while $foo.next". We've got "while" for looping, ".next" for iterating, and "for" for doing both in one convenient little shortcut. So lists and arrays would be iterators, although they may not flaunt it in public. But you could always explicitly call their .next method if you wanted to. For example, for @lines { if s/\\$// # ends with a backslash = continued on next line { $_ ~= @lines.next; redo; } # now process our joined line ... } Of course, that's just the example for "redo" from the Camel, except using an array instead of <>. A P5 array wouldn't have worked, because there's no way to get the "next" iteration of an array in the way that you can use a scalar <> to read the next line of the file. (Though there ought to be a better way of referring to the object of the "for" -- I had to refer to it by name here, but I couldn't do that if it were a list; and $_ is already taken. @_ strikes me as reasonable (for a not necessarily very large value of "reasonable").) I'm not sure how much extra syntax is needed. Something that's expected to iterate (like a filehandle) should just iterate naturally when used in scalar context, or list context, or both. (But a filehandle might stringify to the filename in string context, and return the filehandle object itself when being passed to a function looking for a filehandle.) Something that isn't typically expected to iterate (like an array) could use its .next method, which is a tad wordy, but that's good because that makes it clear and obvious that we are explicitly iterating. Presumably you could slurp up all the iterations at once using * or ** to flatten them. That still doesn't get us the magical <> because it's really a double iteration (over the filenames in @ARGS and then over the contents of each file). In fact, that's just a specific case of wanting to loop through several iterators -- C only loops through the *list* of iterators, not through each object itself. So maybe we do need Larry's new [EMAIL PROTECTED] to get that kind of double-iteration (without having to nest "for" loops, ugh!). Hm. Unless the flattening operator will take care of that. C would do it, but I'm not sure about C. (It would definitely do *something*, of that I'm fairly confident!) But I'm starting to think I may have just been thinking the original problem all along, only inside-out >Hoping I haven't removed all doubt of my foolishness, I'm hoping this reply reassures you. - David "at risk of removing all doubts of mine" Green
Re: Angle quotes and pointy brackets
On Tue, 30 Nov 2004 14:58:13 -0800, Larry Wall <[EMAIL PROTECTED]> wrote: > But then it's not a general iterator iterator. Plus it has the Unicode > taint... > > Back to reality, another thought to weave in here is that something > like > > for $iterator.each -> $x {...} > > might specify that there may be ordering dependencies from loop > iteration to loop iteration, whereas (since junctions are inherently > unordered) saying: > > for $iterator.all -> $x {...} > > explicitly tells the system it can parallelize the loop without worrying > about interation between iterations. I've been thinking about it, and this strikes me as really odd. Perl 5 is full of nice shortcuts. One of them is: for (@array) { which takes the place of for (my $i = 0; $i < @array; $i++) { which is what you'd have to do in a lot of other languages. What I mean is that Perl takes an array and makes an iterator out of it. Sure, you probably don't think about it like that, but the behavior is the same (who says arrays need to iterate starting at element zero?). Java just introduced something similar in 1.5. The odd thing is that here we are designing Perl 6, and we're trying to take an iterator and make it into an array so that we can turn it back into an iterator again. It seems like we should just use it as an iterator:: for $iterator -> $elem { ... } Your message leads me to believe that for all(1, 2, 3) -> $num { ... } is already a special case that will or can be recognized and optimized. If so, having special behavior for an iterator shouldn't be much more difficult (though I'm not sure of the correctness or full ramifications of this statement). That would have the added benefit of letting me write this: for open($filename) or die -> $line { ... } which I like. A method could be used for retrieving the next line/char/byte/whatever: my $fh = open $filename or die; my $line = $fh.next where C<.next> splits on the input record separator. C<.next_byte> and family could be implemented on top of that as well. The biggest problem I see (and I may just be blind) is that for $iterator -> $x { ... } is slightly ambiguous to the programmer, which makes me want angle brackets back. Other syntax could be used (though we seem to be drawing a blank there), but I don't like the idea of using a method (see Iterator->Array->Iterator above). I also like the idea of general iterators. Really like it. Perl 5 had it via C, but it wasn't so pretty. Supposing class Filehandle does Iterate; # Iterate or Iterator? we have an easy way to create new iterators. I'm not sure how useful they would be in Perl 6 (how do iterators compare to lazy lists?), but I can see if being useful. For instance, perhaps a more idiomatic DBI could be written like this: my $sth = $dbh.prepare('SELECT * FROM foo'); for $sth.execute.iter -> $results { ... } Which be even cuter like this (I think): for iter($sth.execute) -> $results { ... } where iter creates an Iterator object that just knows to call C<.next> on its argument. Anyway, take it for what its worth. I'm aware of how ridiculous many of the things we (that includes me) say are, but perhaps I've said something useful. Hoping I haven't removed all doubt of my foolishness, -- matt diephouse http://matt.diephouse.com
Re: Angle quotes and pointy brackets
On Fri, Dec 03, 2004 at 12:56:18AM -0800, Brent 'Dax' Royal-Gordon wrote: : Larry Wall <[EMAIL PROTECTED]> wrote: : > Speaking of "at the moment", I just now updated the Synopses at : > dev.perl.org. : : The new S2 says: : # Heredocs are no longer written with <<, but with an adverb on any other : # quote construct: : # : # print qq:to/END/ : # Give $amount to the man behind curtain number $curtain. : # END : : Does "any other quote construct" include rx//? I've wanted that for a : while in Perl 5 (although with anonymous rules, I suppose it's no : longer that important...). The rx// construct is not an official quote construct because it doesn't produce a string via run-time interpolation. But that doesn't mean you shouldn't get access to :to somehow or other. Either we hack it into the rx adverbs, or maybe we allow a backdoor into q// via some kind of :rx adverb. Especially with the extended syntax being the default, putting your rule over several heredocish lines seems like a real win. But we should probably look at the respective adverbs for q and rx to see if we're setting up any awful cognitive dissonances. I confess I haven't thought about that yet. : # In order to interpolate an entire hash, it's necessary to subscript with : # empty braces or angles: : # : #print "The associations are:\n%bar{}" : #print "The associations are:\n%bar<>" : : Am I to assume you can use empty French/Texas quotes, too? (i.e. : %bar«» or %bar<<>>). Yes. : This paragraph also made me realize: am I the only one who foresees : somebody doing this? : : $OUT.printf("We produced %d somoflanges this month!\n", $content); : : (Granted, the fix is trivial--just replace the double-quotes with : single-quotes, or add some of that optional spacing HTML lets you : splatter around--but it seems like an easy mistake to make.) Probably also a fairly easy mistake to catch if we discourage slash as the first character inside a <...>. So maybe they'd get a warning unless they wrote < /b > instead. Or maybe even an outright compilation error. But there's no doubt that there will be occasional interference between *ML and <> subscripts. : Finally, I noticed that the "Files" section only talks about iterating : over all lines. Do you have a decision on single-line reads yet? Nope, though C is cute. But we still have this fundamental underlying question of how much we want to unify array and iterator notation that hasn't really been resolved. It seems a shame to set up arrays with all these queue-like operations and then not use that to describe, for instance, gather/take queues, or other inter-thread message queues. So what if .[] isn't implemented, or is slow? If you only ever shift/pull an array, does it matter? And really, the essence of arrays is ordering: the indexability is only a side effect of that. But then are we willing to rename shift/unshift to pull/put? If we're gonna go that far, we might as well switch all the bracket characters around. Oh, wait... I suppose it might be argued that if we present a queue as an array, someone will index it instead of shifting it, and end up storing the whole history of the queue in memory. Seems like a weak argument, though. We already have that problem with arrays bound to infinite generators. I guess the only real argument against unifying is that neither of for [EMAIL PROTECTED] {...} or for @foo {...} indicate destructive readout. Which probably says that * is the wrong operator to use for that, which undoes our pretty for * {...} But "for pull" doesn't read very well. Unfortunately we don't have any destructive "all" quantifiers in English that I can think of offhand. I suppose "every" comes about as close as anything. Well, hey, if we have +<< meaning numeric left shift, how about for @foo *<< 1 {...} meaning list left shift? :-) * .999 : [And a note to the editors of dev.perl.org: can we get tables of : contents on these documents? While it's nice to exercise Firefox's : slick find-in-page interface so much on, say, Apocalypse 12, it'd be : more convenient to just have a TOC.] I miss 'em too, but they're admittedly ugly. Maybe they could be put at the end, with a TOC link at the front? Larry
Re: Angle quotes and pointy brackets
Larry Wall <[EMAIL PROTECTED]> wrote: > Speaking of "at the moment", I just now updated the Synopses at > dev.perl.org. The new S2 says: # Heredocs are no longer written with <<, but with an adverb on any other # quote construct: # # print qq:to/END/ # Give $amount to the man behind curtain number $curtain. # END Does "any other quote construct" include rx//? I've wanted that for a while in Perl 5 (although with anonymous rules, I suppose it's no longer that important...). # In order to interpolate an entire hash, it's necessary to subscript with # empty braces or angles: # #print "The associations are:\n%bar{}" #print "The associations are:\n%bar<>" Am I to assume you can use empty French/Texas quotes, too? (i.e. %bar«» or %bar<<>>). This paragraph also made me realize: am I the only one who foresees somebody doing this? $OUT.printf("We produced %d somoflanges this month!\n", $content); (Granted, the fix is trivial--just replace the double-quotes with single-quotes, or add some of that optional spacing HTML lets you splatter around--but it seems like an easy mistake to make.) Finally, I noticed that the "Files" section only talks about iterating over all lines. Do you have a decision on single-line reads yet? [And a note to the editors of dev.perl.org: can we get tables of contents on these documents? While it's nice to exercise Firefox's slick find-in-page interface so much on, say, Apocalypse 12, it'd be more convenient to just have a TOC.] -- Brent 'Dax' Royal-Gordon <[EMAIL PROTECTED]> Perl and Parrot hacker "I might be an idiot, but not a stupid one." --c.l.p.misc (name omitted to protect the foolish)
Re: Angle quotes and pointy brackets
On Thu, Dec 02, 2004 at 09:15:50PM -0800, Larry Wall wrote: : On Thu, Dec 02, 2004 at 02:54:42PM -0700, John Williams wrote: : : Does / <-> / capture to $0{'-'} ? : : Or should that be written / <-«alpha»> / ? : : At the moment I've got it that only assertions of the form capture. Which is a bit odd, insofar as gets captured by that rule... Speaking of "at the moment", I just now updated the Synopses at dev.perl.org. The juiciest new bits are probably in S2, though there are ramifications in any Synopsis marked as having been updated Dec 2. Anonymous enums are kinda cool now: %mo = enum «:Jan(1) Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec»; (The Apocalypses aren't updated yet. Tomorrow maybe, unless I get sucked back into my little pet p5-to-p6 translator project.) Larry
Re: Angle quotes and pointy brackets
On Thu, Dec 02, 2004 at 02:54:42PM -0700, John Williams wrote: : Does / <-> / capture to $0{'-'} ? : Or should that be written / <-«alpha»> / ? At the moment I've got it that only assertions of the form capture. Anything else you have to do an explicit binding, or use :keepall. Larry
Re: Angle quotes and pointy brackets
John Williams writes: > Is all the "Extensible metasyntax (<...>)" being changed to Â... ? > > Or is the new rule that <...> is capturing metasyntax, and Â... is > non-capturing metasyntax? That's the one. > You can't really capture anything on an assertion, so > /^foo .* <( do { say "Got here!" } or 1 )> .* bar$/ > is probably not an issue at all. > > How are the results different between these? > > // Puts 's match object in $ (of the current match object). > /()/ Puts 's match object in $ and its text in $1. > /(ÂidentÂ)/ Puts the text captured by Âident into $1. Luke
Re: Angle quotes and pointy brackets
On Tue, 30 Nov 2004, Larry Wall wrote: > Here's the proposal. > > First the bad news: > * We accept that the C<< < >> operator requires whitespace > around it, and be prepared to be burned in effigy occasionally. My biggest worry about this is that people will be writing if $x<3 loop( $x=0 ; $x<10 ; $x++ ) more than occasionally. > * We steal angles away from iterators. I vote we do that in any case. > Now, that has certain interesting outcomes. > > * We get <...> as the qw// shorthand where a term is expected. > > * Most uses of qw// involve strings and lists, so there's little > visual interference with numeric comparison operators. > > * We get the cute, clean and rather more typeable > > $var[3] I'm starting to like $var{'key1'}{'key2'}[3]{'key3'} more and more. And it's the only way to write $var{'key with spaces'}, right? > * That means that, roughly, we have this proportion: > > '...' : "..." :: <...> : «...» That's definitely worth a cuteness award. > Now with those out of the way, the good news: > * All other uses of «...» and <...> swap, pretty much. Moving this to the end, because I want to request clarification in the context of rules. > * Match vars become $ instead of $«foo». > > * A rule like now captures, while «ws» or <> doesn't. Is all the "Extensible metasyntax (<...>)" being changed to «...» ? Or is the new rule that <...> is capturing metasyntax, and «...» is non-capturing metasyntax? Does / <-> / capture to $0{'-'} ? Or should that be written / <-«alpha»> / ? You can't really capture anything on an assertion, so /^foo .* <( do { say "Got here!" } or 1 )> .* bar$/ is probably not an issue at all. How are the results different between these? // /()/ /(«ident»)/ ~ John Williams
Re: Angle quotes and pointy brackets
On Tue, 30 Nov 2004, Austin Hastings wrote: How about just having C< system() > return a clever object with .output and .err methods? interesting... Michele -- Windows shuts down automaticaly giving an count down. what could be the problem Windows? - "Le TeXnicien de surface" in comp.text.tex
Re: Angle quotes and pointy brackets
On Tue, 30 Nov 2004, Brent 'Dax' Royal-Gordon wrote: I like this in general. However... Larry Wall <[EMAIL PROTECTED]> wrote: * Since we already stole angles from iterators, «$fh» is not how you make iterators iterate. Instead we use $fh.fetch (or whatever) in scalar context, and $fh.fetch or @$fh or $fh[] or *$fh in list context. I believe you tried this one a couple years ago, and people freaked out. As an alternative, could we get a different operator for this? [snip] Any other suggestions, people? I think I will miss angles... well, at least for some time. Of the proposal above I like best @$fh, since it's the one that most conveys the idea of syntactic sugar for iteration while still being fundamentally intuitive. Michele -- Se, nella notte in cui concepi' il duce, Donna Rosa, toccata da divina luce, avesse dato al fabbro predappiano invece della fica il deretano, l'avrebbe presa in culo quella sera Rosa sola e non l'Italia intera. - Poesia antifascista
Re: Angle quotes and pointy brackets
Larry Wall <[EMAIL PROTECTED]> writes: > On Tue, Nov 30, 2004 at 03:03:38PM -0800, Jon Ericson wrote: > : while(<>) {...} > You left out the most important phrase: > > "or whatever we decide is the correctest idiom." I saw that, but I didn't know what to make of it. The Perl 5 idiom is pretty magic and I don't know if it's correcter to make it more or less explicit: for *$ARGV {...} Only I wonder if the magic handle should be called $INPUT or something. > So if, as has been pointed out, @$handle is too much role shear, then we > probably go with something like > > for *$handle {...} > > in which case, if there's no handle, it seems to degrade to > > for * {...} > > which seems amazingly something or other. Lovely? But I'm afraid of extra typing. ;-) It looks like the shell idiom: for f in *; do ...; done Jon
Re: Angle quotes and pointy brackets
On Wed, Dec 01, 2004 at 09:55:32AM +, Matthew Walton wrote: : >I neglected to mention that the smart quoter should also recognize : >pair notation and handle it. : : I've been trying to get my brain round that, but I can't quite figure : out what you mean. Pair notation is, as I understand it, when you get : : key => value : : to construct a pair. Assuming that's me remembering correctly, then : where does the smart quoter have to deal with pair notation? Are you : considering allowing something like: : : « key1 => flop key2 => floop » : : Which would be : : hash(key1 => flop, key2 => floop); : : or am I completely off my rocker? I hope I am, because that's kind of : ugly. Yes, that's the sort of thing I mean. I actually want it for enum defs: my Scalar enum hex « :zero(0) one two three four five six seven eight nine :ten eleven twelve thirteen fourteen fifteen »; : As an aside, is it possible for us to define our own autoquoting : operators? I assume it will be, but I'm feeling insecure and need : reassurance. You can replace the whole darn grammar if you like, so it's certainly possible. I don't think we'll go out of our way to make it easy though. Probably requires a lookahead on the identifier rule to see if the next thing happens to be a => workalike. Alternately, you have to do syntax tree munging with an infix macro, since by the time you see an infix macro its left argument is already parsed. Larry
Re: Angle quotes and pointy brackets
On Wed, 01 Dec 2004 07:41:18 GMT, Smylers <[EMAIL PROTECTED]> wrote: > John Siracusa writes: > > > Call me crazy, but at this point I'm prone to stick with what I've done in > > Perl 5 for years: > > > > $var{'key1'}{'key2'}[3]{'key3'} > > In which case do that, since it'll still work in Perl 6. > [...] > So life is better for people who like writing hash subscripts as you do. > But for those who like autoquoting, there's now a different syntax, one > that doesn't interfere with the above syntax at all. You don't have to > use it if you don't want to, and everybody's happy! Even if I don't use it, I'd like it not to be ugly and awkward (or, heaven forbid, non-ASCII) because I'm likely to have to read and edit it a lot (just as I have to deal with a lot $of{this} these days...sigh) Although I like the single/double angle swap in most places, I'm definitely not a fan of the "fragile fish chain" syntax for hash keys. -John
Re: Angle quotes and pointy brackets
Matthew Walton writes: > Pair notation is, as I understand it, when you get > > key => value That can now also be written as: :key or, where value is 1, simply as: :key I suspect it was this form that Larry was referring to. Smylers
Re: Angle quotes and pointy brackets
Matthew Walton skribis 2004-12-01 10:11 (+): > Well that depends... are you intending to write programs, or drive the > world insane? Yes. Juerd
Re: Angle quotes and pointy brackets
Juerd wrote: Matthew Walton skribis 2004-12-01 9:55 (+): Yes, that would be fun... almost worth throwing out a compiler warning for that, especially if we've still got use warnings. Something like Warning: «{ }» creates empty list It should generate a warning similar to the warning of interpolating an undefined value, but with s/undefined variable/empty list/. Yes, that would make sense. Because I'm sure it should be wrong to create empty circumfix operators. You have to admit that zero width circumfix operators would be VERY NEAT. Well that depends... are you intending to write programs, or drive the world insane?
Re: Angle quotes and pointy brackets
Matthew Walton skribis 2004-12-01 9:55 (+): > Yes, that would be fun... almost worth throwing out a compiler warning > for that, especially if we've still got use warnings. Something like > > Warning: «{ }» creates empty list It should generate a warning similar to the warning of interpolating an undefined value, but with s/undefined variable/empty list/. > Because I'm sure it should be wrong to create empty circumfix operators. You have to admit that zero width circumfix operators would be VERY NEAT. Juerd
Re: Angle quotes and pointy brackets
Larry Wall wrote: I thought so. : I don't think I've ever used a hash slice in my life. Is there something : wrong with me? No, a lot of people are naturally monoindexous. I like that word. : >* The :w splitting happens after interpolation. So : > : > « foo $bar @baz » : > : > can end up with lots of words, while : > : > « foo "$bar" "@baz" » : > : > is guaranteed to end up with three "words". : : See the comment about 'fabulouser' above and add another 'and : fabulouser' to the end. I neglected to mention that the smart quoter should also recognize pair notation and handle it. I've been trying to get my brain round that, but I can't quite figure out what you mean. Pair notation is, as I understand it, when you get key => value to construct a pair. Assuming that's me remembering correctly, then where does the smart quoter have to deal with pair notation? Are you considering allowing something like: « key1 => flop key2 => floop » Which would be hash(key1 => flop, key2 => floop); or am I completely off my rocker? I hope I am, because that's kind of ugly. The only other thing I can think of is if you're just talking about *implementing* infix:=>, in which case just ignore the above because of course the autoquoter needs to recognise its left-hand-side. As an aside, is it possible for us to define our own autoquoting operators? I assume it will be, but I'm feeling insecure and need reassurance. I neglected to mention that we also naturally get both of: circumfix:«< >» circumfix:<« »> in addition to circumfix:{'<','>'} circumfix:{'«','»'} Have to be careful with circumfix:«{ }» though, since {...} interpolates these days. Yes, that would be fun... almost worth throwing out a compiler warning for that, especially if we've still got use warnings. Something like Warning: «{ }» creates empty list or even Warning: circumfix:«{ }» creates empty operator that one could be an error in fact. or if you're feeling really nasty Syntax error Because I'm sure it should be wrong to create empty circumfix operators. Or am I too prescriptive? My inner Haskell programmer is showing through.
Re: Angle quotes and pointy brackets
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Smylers) wrote: >David Green writes: >> I'm not even sure what those double-quotation marks are doing -- [...] >Look back at how Larry defined the guillemets: [...] >So the double-quotes in there are "shell-like", though I guess if you >don't have a Unix background that doesn't mean much to you. Ah, of course. I read that straight in one eye and out the other. =) -David "getting carried away with parallelogies that aren't quite there, but I like the new definition anyway" Green
Re: Angle quotes and pointy brackets
David Green writes: > In article <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] (Larry Wall) wrote: > > >* The :w splitting happens after interpolation. So > >« foo $bar @baz » > >can end up with lots of words, while > >« foo "$bar" "@baz" » > > is guaranteed to end up with three "words". > > Now I'm a bit lost. I would've expected the quotes (") inside a > different kind of quote («) to be taken literally (just as in 'foo > "$bar" "@baz"' or qw/foo "$bar" "@baz"/). > I'm not even sure what those double-quotation marks are doing -- > preventing $bar from being interpolated as a variable, or preventing > the interpolated value from being white-split? Look back at how Larry defined the guillemets: > > * That frees up «...» for Something Else. > > > > * That something else is the requested variant of qw// that > > allows interpolation and quoting of arguments in a shell-like > > manner. So the double-quotes in there are "shell-like", though I guess if you don't have a Unix background that doesn't mean much to you. (Post again if that's the case -- I have to leave for work now, but I'm sure somebody here will be able to explain.) Smylers
Iteration Again (was «Re: Angle quotes and pointy brackets»)
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Brent 'Dax' Royal-Gordon) wrote: >I'm going to pull a Larry and think out >loud for a minute here. Note that I speak authoritatively here, Noted. Or not. =) >Treating it like an array is wrong. >On the other hand, what if a filehandle *is* an array? What if you >can access it randomly and non-destructively? I like this line of thought -- sure, arrays and iterators are different, but they're also similar, so they ought to look similar in at least some ways. We already think of files in a somewhat-array- like manner ("Gimme line 42 of this file") rather than mere iterators ("Get the first 41 lines of this file, throw them away, and then gimme the next one"), so why shouldn't Perl reflect that? Keeping the easy things trivial and all... An iterator can also be quite unlike an array (for instance a pipe, where you can't jump back to the beginning, even inefficiently), but I think those differences apply at a slightly higher level, conceptually. (Or they would if we weren't forced by the language to think of them differently at the lower level.) After all, if you know you're dealing with a pipe, it would probably never even occur to you to try accessing it randomly; on the other hand, if you don't know whether your object is an array or a file or a pipe to begin with, you're already in trouble. >But .shift looks a bit awkward. I suggest a name change for .shift >and .unshift, so that we have: > >push, pop >pull, put Hm, I like that, the parallelisms with the number of letters, and the way they all begin with P. Plus the meanings make sense (you pull something towards you -- that's the front end -- but when something pops off, it goes flying away from you -- that's the back). >So now we have: >my $fh=open "foo.txt"; >say $fh.pull; >for $fh.pullall { I'm not crazy about "pullall". If the idea is we want to slurp up the file right now, can't we use our flattening splatter? (for [EMAIL PROTECTED] ...) >And what about iterators in general? Well, if we can do it to >filehandles, why not all iterators? An iterator is simply a lazy >array copy that isn't accessed randomly; Or maybe a lazy array is just an iterator (with some extra abilities added on). But I'm all for taking advantage of the commonalities. -David "which is related to another kind of laziness" Green
Re: Angle quotes and pointy brackets
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Larry Wall) wrote: >Here's the proposal. >First the bad news: >* We accept that the C<< < >> operator requires whitespace >around it, and be prepared to be burned in effigy occasionally. I wouldn't go that far, although when I inevitably get burned by it, I might let slip some intemperate comparisons regarding whitespace and programming in Python... =) >* That means that, roughly, we have this proportion: >'...' : "..." :: <...> : «...» I wasn't sure at first, but I think you just sold me. (I'm a sucker for parallels.) >* The :w splitting happens after interpolation. So >« foo $bar @baz » >can end up with lots of words, while >« foo "$bar" "@baz" » > is guaranteed to end up with three "words". Now I'm a bit lost. I would've expected the quotes (") inside a different kind of quote («) to be taken literally (just as in 'foo "$bar" "@baz"' or qw/foo "$bar" "@baz"/). I'm not even sure what those double-quotation marks are doing -- preventing $bar from being interpolated as a variable, or preventing the interpolated value from being white-split? (Of course, to keep the pattern going, I'd propose < for no interpolation, << for interpolation (but not subsequent splitting), and introduce <<< for going whole-hog and interpolating *with* subsequent splitting. (Not that I'm saying I'd actually ever use <<>>, I just wanted to propose them for the parallelism.)) >* A rule like now captures, while «ws» or <> doesn't. >I think I really like that last outcome. Capturing should be the default. >And the low profile of «ws» makes it look like an "oh by the way". I don't think I like that as much as you do. I'm not sure I *dislike* it either... but I would be tempted to say that the double guillemets should do twice as much (identify AND capture). That might be simply because I'm not used to it, though. Either way, I know I really like being able to drop the parentheses when capturing like that. Overall, I think the new proposal is an improvement. -David «foo» Green
Re: Angle quotes and pointy brackets
Larry Wall writes: > The basic problem with «...» is that most of its uses were turning out > to be more useful that the corresponding <...>. ... and I think I'm > ready to propose a Great Angle Bracket Renaming. I very much like your proposal. (Though whether you were actually ready to propose it yet is obviously something only you can decide ...) > * We steal angles away from iterators. That means that Apocalypse 2 can be updated by _removing_ an existing "[Update]" block! Most of the complaints about non-Ascii characters in Perl relate to the guillemets. With your proposal they are relegated to much less-commonly constructs, and people who really don't like them can mostly avoid having to go anywhere near them. > * We get <...> as the qw// shorthand where a term is expected. I like that. When Apocalypse 2 first came out I switched to using angles as C delimiters most of the time, such as: use Some::Module qw; in an attempt to get used to them having that meaning, and so there's less of a jump to Perl 6. Over 3 years later I can report that they work very well for this. > * Since we already stole angles from iterators, «$fh» is not > how you make iterators iterate. Instead we use $fh.fetch (or > whatever) in scalar context, and $fh.fetch or @$fh or $fh[] > or *$fh in list context. Good. That is the single thing I find hardest to teach to beginners in Perl 5; output has an explicit C statement, but the input doesn't appear to be anywhere in the code -- there's just some brackets in a C loop, and it doesn't occur to people that brackets might have the effect of reading from a file. However, does anything in this proposal conflict with keeping C< <> > as the special-case token for reading from standard-input-or-the-files- named-on-the-command-line? That way people who like that super-short idiom get to keep it, in: for <> { ... } while anybody who's gone to the bother of typing out a named stream has to put a little more effort in to specify that iteration is required. > * That means that, roughly, we have this proportion: > > '...' : "..." :: <...> : «...» That makes good sense. It also means that people are free to continue to ignore the variant they don't like (such as the many people who prefer to use C<"> quotes in Perl 5 even when no interpolation is required), which to some extent reduces the validity of any carping. Bearing in mind how much more can now be done with out unicode (or ugly C< << > variants) and I think this proposal should result in a nett carping reduction (especially by people who don't following this mailing list closely and therefore haven't been getting used to the previous scheme -- I'm sure it'd be received better by those people who are yet to meet any Perl 6 at all). Smylers
Re: Angle quotes and pointy brackets
John Siracusa writes: > Call me crazy, but at this point I'm prone to stick with what I've done in > Perl 5 for years: > > $var{'key1'}{'key2'}[3]{'key3'} In which case do that, since it'll still work in Perl 6. Actually, it works 'better' in Perl 6, since it doesn't mislead in any way. I've encountered several Perl programmers who feel 'uneasy' about the auto-quoting rules of hash keys, so choose not to bother with them and put all the quotes in as you do above. The trouble with that in Perl 5 is that it gives the impression that the quotes are actually doing something. That then leads to bugs like writing: $log{time} = $msg; where because the programmer has explicitly _not_ used quotes and want to invoke a function rather than use the literal string "time". But because in fact the quotes weren't doing anything, removing them doesn't change anything. That awkwardness is fixed in Perl 6: because the quotes _are_ now needed with the C< $hash{'key'} > syntax when you want to quote, you can not have quotes when you don't want to quote (and Perl will automatically not quote it for you!). So life is better for people who like writing hash subscripts as you do. But for those who like autoquoting, there's now a different syntax, one that doesn't interfere with the above syntax at all. You don't have to use it if you don't want to, and everybody's happy! Smylers
Re: Angle quotes and pointy brackets
On Tue, 30 Nov 2004 19:10:48 -0800, Brent 'Dax' Royal-Gordon <[EMAIL PROTECTED]> wrote: > John Siracusa <[EMAIL PROTECTED]> wrote: > > On 11/30/04 9:54 PM, Matt Diephouse wrote: > > > use CGI «:standard»; > > > [...] > > > use CGi <:standard>; > > > > Who is doing this? I'm just saying... > > > >use CGI ':standard'; > > And won't we just be doing: > > use CGI :standard; > > anyway? Indeed. Also, someone *ahem* will make the following work, with or without the C<.> %hash.:foo:bar:baz = 10; Ashley Winters
Re: Angle quotes and pointy brackets
On Tue, 30 Nov 2004 19:10:48 -0800, Brent 'Dax' Royal-Gordon <[EMAIL PROTECTED]> wrote: > John Siracusa <[EMAIL PROTECTED]> wrote: > > Who is doing this? I'm just saying... > > > >use CGI ':standard'; I normally use qw// when use-ing. *shrug* > And won't we just be doing: > > use CGI :standard; > > anyway? Yeah, we will; I forgot. :-) I don't use Perl 6 very often (yet). -- matt diephouse http://matt.diephouse.com
Re: Angle quotes and pointy brackets
All the cool kids are thinking aloud these days. Why not jump on the bandwagon? Larry Wall writes: > * We get the cute, clean and rather more typeable > > $var[3] It looks like if you shook that up and down a bit, it would break in half. I wonder what would happen if we made <> a little smarter, as in: * acts as a multidimensional subscript (* but what for @array = ?) * <+42> returns a number instead of a string. Then: $var Which is certainly less noisy than the kitkat above. Problems: * -foo is common for options; don't want to force a number. Then again, you don't see -6 as an option too often. * Doesn't solve anything in the practical scenario where some of your keys are not constant. But we'd, of course, do the same thing to ÂÂ. However, there's a problem with ÂÂ: it doesn't generalize to non-string keys (since Â$foo can reasonably only stringify). That is: $varÂfoo ; $bar ; +3 Doesn't work if $bar is something unstringly that happens to be the key type of the second dimension. Not to mention that if we allowed semicolon,  would be the common one again, and we'd be in for another switcheroo. Anyway, I think there's something wrong with: $var[3] It doesn't hold together visually. This might have some relation to the other problem on my mind: the difference between $, @, and % these days. The rest of the proposal is pretty snazzy, though. Luke
Re: Angle quotes and pointy brackets
John Siracusa <[EMAIL PROTECTED]> wrote: > On 11/30/04 9:54 PM, Matt Diephouse wrote: > > use CGI «:standard»; > > [...] > > use CGi <:standard>; > > Who is doing this? I'm just saying... > >use CGI ':standard'; And won't we just be doing: use CGI :standard; anyway? -- Brent 'Dax' Royal-Gordon <[EMAIL PROTECTED]> Perl and Parrot hacker "I might be an idiot, but not a stupid one." --c.l.p.misc (name omitted to protect the foolish)
Re: Angle quotes and pointy brackets
On 11/30/04 9:54 PM, Matt Diephouse wrote: > use CGI «:standard»; > [...] > use CGi <:standard>; Who is doing this? I'm just saying... use CGI ':standard'; It really ain't all that broke, is it? -John
Re: Angle quotes and pointy brackets
On Tue, 30 Nov 2004 13:35:37 -0800, Larry Wall <[EMAIL PROTECTED]> wrote: > The basic problem with «...» is that most of its uses > were turning out to be more useful that the corresponding <...>. > In fact, I was thinking about all this on the way home from Seattle > yesterday (a 15-hour drive), and I think I'm ready to propose a Great > Angle Bracket Renaming. I'm going to be difficult and say I don't actually like this proposal. I think « and » are much more attractive than < and >, and I don't mind the extra work to type them. « and » are more visually distinctive, at least in my mind. Specifically, I like that they line up with the tops of lower case letters. But I doubt that matters much. :-) use CGI «:standard»; my @list = «foo bar baz»; my @other = %hash«several keys here»; use CGi <:standard>; my @list = ; my @other = %hash; (Those are written out for my own benefit; consider it a goodbye.) -- matt diephouse http://matt.diephouse.com
Re: Angle quotes and pointy brackets
On 11/30/04 6:35 PM, James Mastros wrote: > Austin Hastings wrote: >> Larry Wall wrote: >>>* We get the cute, clean and rather more typeable >>> >>> $var[3] "Cute" maybe (looks like a chain of fish) > The problem with {} for a hash dereference operator is not it's > typeablility, but rather it's autoquoting behavior from perl5. Call me crazy, but at this point I'm prone to stick with what I've done in Perl 5 for years: $var{'key1'}{'key2'}[3]{'key3'} It's the same number of characters as: $var<><>[3]<> and it requires no "funny" characters. I also find it a heck of a lot more readable than any of the others. The {' '} makes a nice vertical + whitespace "frame" around the key. The fake doubles << and >> are way too noisy. The funny quotes look wildly different in different fonts, but usually end up as indistinct smudges that resemble melted "=" characters. > OTOH, $wheel. and $wheel. are both literals. (The dot > there is optional.) (Until a little bit ago, that was $wheel.<> > or $wheel.«roll». (Note that I had to switch keyboard layouts again to > type that.)) I agree that $wheel is an improvement over $wheel«roll» and $wheel<> (although I can't decide which of those two is worse), but I still think $wheel{'roll'} is the clear winner in all respects except perhaps speed of typing. -John
Re: Angle quotes and pointy brackets
On Tue, Nov 30, 2004 at 03:03:38PM -0800, Jon Ericson wrote: : Larry Wall <[EMAIL PROTECTED]> writes: : : > The p5-to-p6 translator will turn any : > : > while () {...} : > : > into : > : > for @$handle {...} : : Including: : : while(<>) {...} : : to : : for @$ {...} : : ? You left out the most important phrase: "or whatever we decide is the correctest idiom." So if, as has been pointed out, @$handle is too much role shear, then we probably go with something like for *$handle {...} in which case, if there's no handle, it seems to degrade to for * {...} which seems amazingly something or other. Larry
Re: Angle quotes and pointy brackets
On Tue, Nov 30, 2004 at 06:27:55PM -0500, Matt Fowles wrote: : Even if he wasn't cackling, I admit to feeling it. I don't even use : the qx/qq/qw stuff in perl5. I always got by with "". : : Although I must admit to liking python's C< r"..." > meaning : absolutely raw string (useful for avoiding double escape problems with : their regular expressions). Left me thinking it was short for regex : and not raw for a little while... Actually, I was thinking about a raw option, so q:r could be it. And it might actually turn out to be useful for quoting rules if for some reason you really don't want to write an rx//. And oddly, it might end up with a qr// shorthand. So we might end up with qr:here'END' for the Perl 6 equivalent to <<'END'. Larry
Re: Angle quotes and pointy brackets
On Tue, Nov 30, 2004 at 05:39:29PM -0700, Luke Palmer wrote: : I don't know what argumentless shift does now. It probably works on : @*ARGS when you're in the main program, but inside a sub... I dunno. : Maybe it shifts from the slurpy array argument. Shifting on the topic : seems wrong (since you could use .shift for that). I'd say it always shifts the slurpy array, and in Main the slurpy array just happens to be named [EMAIL PROTECTED] Larry
Re: Angle quotes and pointy brackets
James Mastros writes: > The problem with {} for a hash dereference operator is not it's > typeablility, but rather it's autoquoting behavior from perl5. In > perl5, the contents of {foo} are a string -- except when they aren't. > Quick: > > $wheel->{roll} = 3; > $wheel->{shift} = 4; > > In perl5, the first is a literal, the second shifts from @_. Whoops. That's wrong. I can't determine whether you knew it was wrong, and your final assessment sentence was intentionally wrong (thus "Whoops"). But, in Perl 5, they're both literals. > In perl6, the contents of {} is an expression. The first is an error > unless a function named roll is available (or a method on the topic?). > The second is good old shift (on the topic now). I don't know what argumentless shift does now. It probably works on @*ARGS when you're in the main program, but inside a sub... I dunno. Maybe it shifts from the slurpy array argument. Shifting on the topic seems wrong (since you could use .shift for that). Luke
Re: Angle quotes and pointy brackets
On Tue, Nov 30, 2004 at 02:26:06PM -0800, Brent 'Dax' Royal-Gordon wrote: : Larry Wall <[EMAIL PROTECTED]> wrote: : > * Since we already stole angles from iterators, «$fh» is not : > how you make iterators iterate. Instead we use $fh.fetch (or : > whatever) in scalar context, and $fh.fetch or @$fh or $fh[] : > or *$fh in list context. : : I believe you tried this one a couple years ago, and people freaked : out. As an alternative, could we get a different operator for this? : I propose one of: : : $fh -> : $fh» (and $fh>>) : $fh> : : All three have connotations of "the next thing". The first one might : interfere with pointy subs, though, and the last two would be : whitespace-sensitive. (But it looks like that isn't a bad thing : anymore...) In lines with the '...' "..." and <...> <<...>> progressions, the following progression has a nice symmetry: $iter -->#extract next (one) element from iterator $iter $iter ==>#pipeline all elements (lazy) in turn from iterator $iter However, I haven't been paying a lot of attention, to the current state of affairs, so it is probably broken in some way. --
Re: Angle quotes and pointy brackets
> "AH" == Austin Hastings <[EMAIL PROTECTED]> writes: AH> Larry Wall wrote: >> * We get the cute, clean and rather more typeable >> >> $var[3] >> AH> No more or less typeable for me, or anyone else who can remap their AH> keyboard. I'm presuming there's something costly about {} on non-US AH> keyboards, but how much does it cost? and do those non-US perl hacks AH> use remapping already? i think the diff between $hash<> and $hash{} is that <> autoquotes (and only allows) single words and {} requires quote words or expressions. so $hash is the same as $hash{'foo'}. $hash{foo} is either a syntax error or something i can't figure out (foo is a bareword which is illegal IIRC). >> * People can probably get used to reading things like: >> >> $var[3] < $var[4] >> AH> It's just as readable as XML. it is only for fixed token keys and who actually writes hash accesses that deep and very often? i would assign the midlevel hashes to a scalar and work from there if this was common code. AH> Carp. AH> Carp. AH> Carp. main::Carp can't be found. Perhaps you forgot to use the Carp qw(no_carping_at_larry)? :) uri -- Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com --Perl Consulting, Stem Development, Systems Architecture, Design and Coding- Search or Offer Perl Jobs http://jobs.perl.org
Re: Angle quotes and pointy brackets
> "MW" == Matthew Walton <[EMAIL PROTECTED]> writes: MW> I don't think I've ever used a hash slice in my life. Is there MW> something wrong with me? yes! :) see http://www.sysarch.com/perl/tutorials/hash_slice.txt for why they are so cool. >> * The Texas quotes <<...>> are only needed when you *have* to interpolate. MW> Does MW> <> MW> mean MW> «foo bar baz» i would hope << and >> always mean the same as their unicode versions. i will be typing the long asci versions for as long as it takes me to learn how to key the unicode in emacs (i know people have posted answers for emacs but it still takes my tiny brane a while to learn new keystrokes). >> * Match vars become $ instead of $«foo». >> * A rule like now captures, while «ws» or <> doesn't. >> I think I really like that last outcome. Capturing should be the >> default. >> And the low profile of «ws» makes it look like an "oh by the way". i thought we had very different capturing and non-capturing syntax? and with equal key counts as well. but i could be out of date with regard to rules and grammars. i dread ruining more brane cells reading the recent updated apocs and such. :) uri -- Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com --Perl Consulting, Stem Development, Systems Architecture, Design and Coding- Search or Offer Perl Jobs http://jobs.perl.org
Re: Angle quotes and pointy brackets
Austin Hastings wrote: Larry Wall wrote: * We get the cute, clean and rather more typeable $var[3] No more or less typeable for me, or anyone else who can remap their keyboard. I'm presuming there's something costly about {} on non-US keyboards, but how much does it cost? and do those non-US perl hacks use remapping already? German keyboard, for example: { -- right alt, and the 7 key [ -- right alt, and the 8 key ] -- right alt, and the 9 key } -- right alt, and the 0 key German keyboard under xfree86 but not windows: « -- right alt, z (Well, the key that's z on an American keyboard). » -- right alt, x Those are /really/ hard to type, esp }, which comes up a /lot/ in perl, weather 5 or 6, which is a big reason that I use the American keymap, which is a constant annoyance to my girlfriend, who uses the British keymap. (We're an American and a Brit, living in Germany.) The problem with {} for a hash dereference operator is not it's typeablility, but rather it's autoquoting behavior from perl5. In perl5, the contents of {foo} are a string -- except when they aren't. Quick: $wheel->{roll} = 3; $wheel->{shift} = 4; In perl5, the first is a literal, the second shifts from @_. Whoops. In perl6, the contents of {} is an expression. The first is an error unless a function named roll is available (or a method on the topic?). The second is good old shift (on the topic now). OTOH, $wheel. and $wheel. are both literals. (The dot there is optional.) (Until a little bit ago, that was $wheel.<> or $wheel.«roll». (Note that I had to switch keyboard layouts again to type that.)) -=- James Mastros
Re: Angle quotes and pointy brackets
Rod Adams <[EMAIL PROTECTED]> wrote: > >$fh -> > >$fh» (and $fh>>) > >$fh> > ++$fh That kind of breaks the metaphor, unfortunately. I've been thinking more on this, and I may have a better reason for not liking this proposal. I'm going to pull a Larry and think out loud for a minute here. Note that I speak authoritatively here, as if I'm the language designer; this is just to avoid putting "I would..." everywhere. I think my problem with the proposed syntax is metaphor shear. This example code: for (@$input) { ... } works whether $input is a filehandle or an arrayref. So a user may decide to do this: say $input[42]; which I suspect won't work. Even if it does, this code: for(@$input) { ... } say $input[0]; probably wouldn't. The problem is that filehandles are iterators--which aren't arrays. An iterator has different characteristics from an array--i.e. it's accessed more or less sequentially and access is destructive. Treating it like an array is wrong. On the other hand, what if a filehandle *is* an array? What if you can access it randomly and non-destructively? If it is, we already have a name for "fetch". In Perl 5, we call a destructive fetch from the front of an array "shift". So: $fh=open "foo.txt"; say $fh.shift; for $fh.shift($fh.elems) { ... } Of course, $fh.shift($fh.elems) deserves a shortcut. Perhaps $fh.shiftall(), which creates a lazy copy and "empties" the filehandle. But .shift looks a bit awkward. I suggest a name change for .shift and .unshift, so that we have: push, pop pull, put So now we have: my $fh=open "foo.txt"; say $fh.pull; for $fh.pullall { ... } And what about iterators in general? Well, if we can do it to filehandles, why not all iterators? An iterator is simply a lazy array copy that isn't accessed randomly; instead, the .pull and .pullall methods are used for access. .push can be used to append to it, .put can be used to put an item back on the front. .pop is a bit useless, but that's not really a problem. That doesn't mean you *can't* randomly access an iterator--after all, it's just a lazy array copy. But it might be slower, or otherwise unwise. At the point where a filehandle is just an array and you can use most normal array operations on it, I can see not having a special operator for reading a file. Without that, though, I think the metaphor shear of @$fh is too harsh, and the duplication between .fetch and .[shift|pull] isn't necessary. -- Brent 'Dax' Royal-Gordon <[EMAIL PROTECTED]> Perl and Parrot hacker "I might be an idiot, but not a stupid one." --c.l.p.misc (name omitted to protect the foolish)
Re: Angle quotes and pointy brackets
Austin~ On Tue, 30 Nov 2004 18:15:54 -0500, Austin Hastings <[EMAIL PROTECTED]> wrote: > Austin Hastings wrote: > > > Larry Wall wrote: > > And now, Piers is cackling madly at Matt: welcome to "perl6-hightraffic!" > > :-) Even if he wasn't cackling, I admit to feeling it. I don't even use the qx/qq/qw stuff in perl5. I always got by with "". Although I must admit to liking python's C< r"..." > meaning absolutely raw string (useful for avoiding double escape problems with their regular expressions). Left me thinking it was short for regex and not raw for a little while... Matt -- "Computer Science is merely the post-Turing Decline of Formal Systems Theory." -???
Re: Angle quotes and pointy brackets
Austin Hastings wrote: Larry Wall wrote: And now, Piers is cackling madly at Matt: welcome to "perl6-hightraffic!" :-) =Austin
Re: Angle quotes and pointy brackets
Larry Wall wrote: I'm ready to propose a Great Angle Bracket Renaming. Hajleuja! Praise the Larry!* It looks wonderful, and just fixed half about half the things I was worried about having to do when programming perl6. (Not that hard -- I can't think of any more at the moment, but I'm sure they're there somewhere.) -=- James Mastros *I think I just broke two or three commandments.
Re: Angle quotes and pointy brackets
Larry Wall wrote: * We get the cute, clean and rather more typeable $var[3] No more or less typeable for me, or anyone else who can remap their keyboard. I'm presuming there's something costly about {} on non-US keyboards, but how much does it cost? and do those non-US perl hacks use remapping already? * People can probably get used to reading things like: $var[3] < $var[4] It's just as readable as XML. * Though they will certainly carp. Carp. Carp. Carp. * The ordinary angles do a better job of turning the literal keys into visual pills than «...» do. What're the objectives here again? Sorry, but <> don't turn ANYTHING into "visual pills". They never have. (HT|X)ML looks like gobbledygook interspersed with low-slung X's. The line above reads like a IOCCC loser. * Since we already stole angles from iterators, «$fh» is not how you make iterators iterate. Instead we use $fh.fetch (or whatever) in scalar context, and $fh.fetch or @$fh or $fh[] or *$fh in list context. while ($.fetch) ?? * That frees up «...» for Something Else. * That something else is the requested variant of qw// that allows interpolation and quoting of arguments in a shell-like manner. Sorry, why wouldn't `` work? How about just having C< system() > return a clever object with .output and .err methods? * That means that, roughly, we have this proportion: '...' : "..." :: <...> : «...» Have we discussed which quote-like operator is going to stand for "eval"? There's a number of different post-processing things you can do with string literals, with interpolation at one end of the spectrum and execution at the other. Why not just write this down as "these are all just special cases of XXX behavior", and then build some handles onto XXX, a la NEXT, LAST, etc. Then provide "standard bindings" for '', ``, "", and //. * Therefore, just as you can use "..." in place of '...' where you you think it's more readable, you may still use «...» in place of <...> where that helps readability. my $foo = `*.c` :post(literal); # *.c my $bar = /$foo/ :post(glob); # a.c b.c ... my $cmd = 'echo $foo' :post(interpolate); # echo *.c my $output = q{$cmd} :post(exec);# *.c my $files = "$cmd" :post(shell); # a.c b.c ... $var«key1»«key2»[3]«key3» < $var«key1»«key2»[4]«key3» I'm looking for the goodness, and I'm just preferring the more vertical {} as parallels with []. * The Texas quotes <<...>> are only needed when you *have* to interpolate. Not even a little bit sure what this means. If non-interpolation is an option, put a modifier on it. * Multimethed references could be distinghuised either way: &bark«Tree» &bark At some point, nestled « was considered a short-circuit of the paren/hash. Is that supposed to stand, or are those quotes? * Match vars become $ instead of $«foo». Seems independent of the others. Is this just a consistency issue? * A rule like now captures, while «ws» or <> doesn't. So <...>, which is analogous to '...' above, doesn't interpolate but does capture? While «...», which is analogous to "...", does interpolate but doesn't capture? I think I really like that last outcome. Capturing should be the default. And the low profile of «ws» makes it look like an "oh by the way". I think that last sentence sums it up: using «ws» is less visually obvious. For scenarios where we don't want visual obviousness, like string delimiters, that's probably a win. I really don't want stealth paint on my data infrastructure, though. Larry =Austin
Re: Angle quotes and pointy brackets
Larry Wall <[EMAIL PROTECTED]> writes: > The p5-to-p6 translator will turn any > > while () {...} > > into > > for @$handle {...} Including: while(<>) {...} to for @$ {...} ? Jon
Re: Angle quotes and pointy brackets
On Tue, Nov 30, 2004 at 02:26:06PM -0800, Brent 'Dax' Royal-Gordon wrote: : I like this in general. However... : : Larry Wall <[EMAIL PROTECTED]> wrote: : > * Since we already stole angles from iterators, Â$fh is not : > how you make iterators iterate. Instead we use $fh.fetch (or : > whatever) in scalar context, and $fh.fetch or @$fh or $fh[] : > or *$fh in list context. : : I believe you tried this one a couple years ago, and people freaked : out. As an alternative, could we get a different operator for this? : I propose one of: : : $fh -> : $fh (and $fh>>) : $fh> : : All three have connotations of "the next thing". The first one might : interfere with pointy subs, though, and the last two would be : whitespace-sensitive. (But it looks like that isn't a bad thing : anymore...) : : Any other suggestions, people? Well, the IO::All folks will have their own ideas. The thing I don't like about IO::All is the way it overloads angles. So maybe if we have $foo â io('myfile') we also get the unary: â io('myfile') Actually, if you buy the metaphor that the filesystem is "below", then I kinda like: $foo â io('myfile') and âio('myfile') But then it's not a general iterator iterator. Plus it has the Unicode taint... Back to reality, another thought to weave in here is that something like for $iterator.each -> $x {...} might specify that there may be ordering dependencies from loop iteration to loop iteration, whereas (since junctions are inherently unordered) saying: for $iterator.all -> $x {...} explicitly tells the system it can parallelize the loop without worrying about interation between iterations. Larry
Re: Angle quotes and pointy brackets
On Nov 30, 2004, at 2:46 PM, Larry Wall wrote: : I assume that each value would be still fetched from the file handle : lazily, yes? Um, that was the question my "Correct" was answering. D'oh! Sorry. David
Re: Angle quotes and pointy brackets
On Tue, Nov 30, 2004 at 02:40:01PM -0800, David Wheeler wrote: : On Nov 30, 2004, at 2:23 PM, Larry Wall wrote: : : >Correct. The p5-to-p6 translator will turn any : > : >while () {...} : > : >into : > : >for @$handle {...} : : I assume that each value would be still fetched from the file handle : lazily, yes? Um, that was the question my "Correct" was answering. Larry
Re: Angle quotes and pointy brackets
Brent 'Dax' Royal-Gordon wrote: I like this in general. However... Larry Wall <[EMAIL PROTECTED]> wrote: * Since we already stole angles from iterators, «$fh» is not how you make iterators iterate. Instead we use $fh.fetch (or whatever) in scalar context, and $fh.fetch or @$fh or $fh[] or *$fh in list context. I believe you tried this one a couple years ago, and people freaked out. As an alternative, could we get a different operator for this? I propose one of: $fh -> $fh» (and $fh>>) $fh> All three have connotations of "the next thing". The first one might interfere with pointy subs, though, and the last two would be whitespace-sensitive. (But it looks like that isn't a bad thing anymore...) Any other suggestions, people? ++$fh
Re: Angle quotes and pointy brackets
On Nov 30, 2004, at 2:23 PM, Larry Wall wrote: Correct. The p5-to-p6 translator will turn any while () {...} into for @$handle {...} I assume that each value would be still fetched from the file handle lazily, yes? Regards, David
Re: Angle quotes and pointy brackets
I like this in general. However... Larry Wall <[EMAIL PROTECTED]> wrote: > * Since we already stole angles from iterators, «$fh» is not > how you make iterators iterate. Instead we use $fh.fetch (or > whatever) in scalar context, and $fh.fetch or @$fh or $fh[] > or *$fh in list context. I believe you tried this one a couple years ago, and people freaked out. As an alternative, could we get a different operator for this? I propose one of: $fh -> $fh» (and $fh>>) $fh> All three have connotations of "the next thing". The first one might interfere with pointy subs, though, and the last two would be whitespace-sensitive. (But it looks like that isn't a bad thing anymore...) Any other suggestions, people? -- Brent 'Dax' Royal-Gordon <[EMAIL PROTECTED]> Perl and Parrot hacker "I might be an idiot, but not a stupid one." --c.l.p.misc (name omitted to protect the foolish)
Re: Angle quotes and pointy brackets
On Tue, Nov 30, 2004 at 10:05:03PM +, Matthew Walton wrote: : So : : my @list = ; : : is the equivalent of : : my @list = ('foo', 'bar', 'baz'); : : ? Yes. : >* Since we already stole angles from iterators, «$fh» is not : > how you make iterators iterate. Instead we use $fh.fetch (or : > whatever) in scalar context, and $fh.fetch or @$fh or $fh[] : > or *$fh in list context. : : That's doable. I take it that if I do : : for (@$fh) { : ... : } : : then $fh iterates lazily rather than exploding into an enormous list to : be processed and chewing up all the RAM. Correct. The p5-to-p6 translator will turn any while () {...} into for @$handle {...} or whatever we decide is the correctest idiom. : >* That frees up «...» for Something Else. : > : >* That something else is the requested variant of qw// that allows : > interpolation and quoting of arguments in a shell-like manner. : : Mmmm so I can write : : my $foo = 'foo'; : my $bar = 'bar'; : my $baz = 'baz'; : my @list = «$foo $bar $baz»; : : and get the same @list I got earlier? Mighty cool. I thought so. : I don't think I've ever used a hash slice in my life. Is there something : wrong with me? No, a lot of people are naturally monoindexous. : >* The Texas quotes <<...>> are only needed when you *have* to : >interpolate. : : Does : : <> : : mean : : «foo bar baz» : : or : : ('') : : ? The former. The <<...>> workaround is still the same, but needed a lot less. : >* The :w splitting happens after interpolation. So : > : > « foo $bar @baz » : > : > can end up with lots of words, while : > : > « foo "$bar" "@baz" » : > : > is guaranteed to end up with three "words". : : See the comment about 'fabulouser' above and add another 'and : fabulouser' to the end. I neglected to mention that the smart quoter should also recognize pair notation and handle it. : >* Multimethed references could be distinghuised either way: : > : > &bark«Tree» : > &bark : : Good, so those of us who wish to use as much Unicode as possible can do : so without having to rewrite the grammar. Excellent ;-) I neglected to mention that we also naturally get both of: circumfix:«< >» circumfix:<« »> in addition to circumfix:{'<','>'} circumfix:{'«','»'} Have to be careful with circumfix:«{ }» though, since {...} interpolates these days. Larry
Re: Angle quotes and pointy brackets
Larry Wall wrote: I rather like it too. I'm glad someone else is thinking along the same lines. The basic problem with «...» is that most of its uses were turning out to be more useful that the corresponding <...>. In fact, I was thinking about all this on the way home from Seattle yesterday (a 15-hour drive), and I think I'm ready to propose a Great Angle Bracket Renaming. Well... this is interesting. I'm wondering, should I recycle my copy of Perl 6 and Parrot Essentials, or keep it as an historical document for future generations to look at and marvel over? Just kidding, I'm surprising myself by liking this. Let's see if I've understood it. Here's the proposal. First the bad news: * We accept that the C<< < >> operator requires whitespace around it, and be prepared to be burned in effigy occasionally. Personally, I always use whitespace around such operators, so it's no hassle for me for it to be required. Might encourage some more readable code (definition of 'readable' unfortunately still undecided across the programming community). * We steal angles away from iterators. Will they miss them? In a way it's nice to have syntax-level support for iteration, but it's no massive hardship to do without. Now the ugly news: * Hyper operators stay the same, »op«. That's not ugly. Now with those out of the way, the good news: * All other uses of «...» and <...> swap, pretty much. Now, that has certain interesting outcomes. * We get <...> as the qw// shorthand where a term is expected. So my @list = ; is the equivalent of my @list = ('foo', 'bar', 'baz'); ? * Most uses of qw// involve strings and lists, so there's little visual interference with numeric comparison operators. Very true. * People can probably get used to reading things like: $var[3] < $var[4] * Though they will certainly carp. They always do. * Since we already stole angles from iterators, «$fh» is not how you make iterators iterate. Instead we use $fh.fetch (or whatever) in scalar context, and $fh.fetch or @$fh or $fh[] or *$fh in list context. That's doable. I take it that if I do for (@$fh) { ... } then $fh iterates lazily rather than exploding into an enormous list to be processed and chewing up all the RAM. * That frees up «...» for Something Else. * That something else is the requested variant of qw// that allows interpolation and quoting of arguments in a shell-like manner. Mmmm so I can write my $foo = 'foo'; my $bar = 'bar'; my $baz = 'baz'; my @list = «$foo $bar $baz»; and get the same @list I got earlier? Mighty cool. * That means that, roughly, we have this proportion: '...' : "..." :: <...> : «...» Elegance, always good. * Therefore, just as you can use "..." in place of '...' where you you think it's more readable, you may still use «...» in place of <...> where that helps readability. $var«key1»«key2»[3]«key3» < $var«key1»«key2»[4]«key3» Fabulouser and fabulouser. * Both the «...» and <...> forms work as slices when used as hash subscripts. I don't think I've ever used a hash slice in my life. Is there something wrong with me? * The Texas quotes <<...>> are only needed when you *have* to interpolate. Does <> mean «foo bar baz» or ('') ? * The :w splitting happens after interpolation. So « foo $bar @baz » can end up with lots of words, while « foo "$bar" "@baz" » is guaranteed to end up with three "words". See the comment about 'fabulouser' above and add another 'and fabulouser' to the end. * Multimethed references could be distinghuised either way: &bark«Tree» &bark Good, so those of us who wish to use as much Unicode as possible can do so without having to rewrite the grammar. Excellent ;-) * Match vars become $ instead of $«foo». * A rule like now captures, while «ws» or <> doesn't. I think I really like that last outcome. Capturing should be the default. And the low profile of «ws» makes it look like an "oh by the way". Unfortunately the ASCII equivalent doesn't have quite such a low profile, but I think I can live with that, since I can handle «» on all my Perl-coding systems. And the alternatives are still there for those who can't. In many ways this seems clearer than the old way. I like it.
Re: Angle quotes and pointy brackets
On Tue, Nov 30, 2004 at 09:09:39AM +0300, Alexey Trofimenko wrote: : When I look at this :$var[3] : : then I think that it's a *very* cute, nice, and clean syntax... I really : like it! : (and I would sacrifice something for that to happen, if I would be Larry : :) ) : but there's a problem for people and parser too. < is a comparison : *operator* and hash subscript is *operator* too, and there's no way to : distinguish them at all. "Term rule" won't help here. I rather like it too. I'm glad someone else is thinking along the same lines. The basic problem with «...» is that most of its uses were turning out to be more useful that the corresponding <...>. In fact, I was thinking about all this on the way home from Seattle yesterday (a 15-hour drive), and I think I'm ready to propose a Great Angle Bracket Renaming. Here's the proposal. First the bad news: * We accept that the C<< < >> operator requires whitespace around it, and be prepared to be burned in effigy occasionally. * We steal angles away from iterators. Now the ugly news: * Hyper operators stay the same, »op«. Now with those out of the way, the good news: * All other uses of «...» and <...> swap, pretty much. Now, that has certain interesting outcomes. * We get <...> as the qw// shorthand where a term is expected. * Most uses of qw// involve strings and lists, so there's little visual interference with numeric comparison operators. * We get the cute, clean and rather more typeable $var[3] * People can probably get used to reading things like: $var[3] < $var[4] * Though they will certainly carp. * The ordinary angles do a better job of turning the literal keys into visual pills than «...» do. * Since we already stole angles from iterators, «$fh» is not how you make iterators iterate. Instead we use $fh.fetch (or whatever) in scalar context, and $fh.fetch or @$fh or $fh[] or *$fh in list context. * That frees up «...» for Something Else. * That something else is the requested variant of qw// that allows interpolation and quoting of arguments in a shell-like manner. * That means that, roughly, we have this proportion: '...' : "..." :: <...> : «...» * Therefore, just as you can use "..." in place of '...' where you you think it's more readable, you may still use «...» in place of <...> where that helps readability. $var«key1»«key2»[3]«key3» < $var«key1»«key2»[4]«key3» * Both the «...» and <...> forms work as slices when used as hash subscripts. * The Texas quotes <<...>> are only needed when you *have* to interpolate. * The :w splitting happens after interpolation. So « foo $bar @baz » can end up with lots of words, while « foo "$bar" "@baz" » is guaranteed to end up with three "words". * Multimethed references could be distinghuised either way: &bark«Tree» &bark * Match vars become $ instead of $«foo». * A rule like now captures, while «ws» or <> doesn't. I think I really like that last outcome. Capturing should be the default. And the low profile of «ws» makes it look like an "oh by the way". Anyway, feel free to shoot this full of holes. Larry
Re: Angle quotes and pointy brackets
Brent 'Dax' Royal-Gordon skribis 2004-11-30 9:28 (-0800): > > A request to everyone who wants to discuss this again: please, read the > > Backticks thread. Almost everything that can be said about this subject > > has already been said before. > Not to put too fine a point on it, but "everything" includes Larry's > rejection of the idea. True. There are however some things that "almost everything" does not include, and evidently there is still the need for some to discuss this subject. Juerd
Re: Angle quotes and pointy brackets
On Tue, Nov 30, 2004 at 03:17:42AM +0300, Alexey Trofimenko wrote: : Why to introduce (or REintroduce) something if we have something : similar already? : : $captured = system :capture q/cmd../; By the way, that one happens to be illegal at the moment. To use pairs as part of an argument list you have to install a comma like this: $captured = system :capture, q/cmd../; As it currently stands, you may only omit comma between :pairs. Otherwise we don't know how to parse this: print $y / $x :round(2) / 3; With an assumed comma after the :round(2), the / would be taken as the start of a pattern. Possibly we can fix this for :pairs that are the first thing a list, though. It seems to be a trap that p6l'ers keep falling into. Larry
Re: Angle quotes and pointy brackets
Juerd <[EMAIL PROTECTED]> wrote: > A request to everyone who wants to discuss this again: please, read the > Backticks thread. Almost everything that can be said about this subject > has already been said before. Not to put too fine a point on it, but "everything" includes Larry's rejection of the idea. -- Brent 'Dax' Royal-Gordon <[EMAIL PROTECTED]> Perl and Parrot hacker "I might be an idiot, but not a stupid one." --c.l.p.misc (name omitted to protect the foolish)
Re: Angle quotes and pointy brackets
Juerd wrote: A request to everyone who wants to discuss this again: please, read the Backticks thread. Almost everything that can be said about this subject has already been said before. It is a huge thread, and let's not copy everything here. I'd like to apologize for bringing it up (while trying, and apparently failing, not to). -=- James Mastros
Re: Angle quotes and pointy brackets
A request to everyone who wants to discuss this again: please, read the Backticks thread. Almost everything that can be said about this subject has already been said before. It is a huge thread, and let's not copy everything here. Alexey Trofimenko skribis 2004-11-30 14:34 (+0300): > but it puts big restrictions on what can be part of the name (actually, > thoose which match to only), so $package'$varname won't work. > I meant only that your ` can't be replacement to « » because latter allows > MUCH more freedom in key names. Actually, only space has special meaning > here. I suggest that you re-read the Backticks thread of April this year. Summarized in reaction to above snippet: it would not be the only place where Perl's syntax is optimized for the most common use, but has an alternative available. I don't recall ever having said that %hash`key was a *replacement* for %hash«key». > so, could you be more explicit, what rules your syntax have? I cannot be much more explicit than in referenced thread, but since you ask specific questions, I will answer them. > $a`$b+$c`$d, is it equivalent of > $a[$b+$c][$d] or $a[$b]+$c[$d] ? The latter. I intended whetever is seen as a string in Perl 5 $hash{key} to be valid. In general, that is: any valid identifier (except it may start with a digit, and optionally have a - before it). Should you want to play with the syntax, then use Matthijs' patch for Perl 5, which enables the backticks for hash element selection. > and I think, polymorphic treating of ` as either {} or [] adds some > overhead.. and unstability of your code. Then have it just for hashes. I don't think it is at all true, though. > Especially in cases like $a`$b, > when compiler just can't see in compiler time, what could be contained in > $b - number or string. I suggested deciding based on the value of the RHS once, but no longer support that. The decision should be based on the LHS alone, and if the LHS supports both postcircumfix:«{ }» and postcircumfix:«[ ]», then the {} wins. > no spaces allowed, no expressions, and it is always a HASH subscript. No expressions, but a simple "atomic" scalar variable should be allowed, as is true for methods too: $foo.bar $foo.$bar Re spaces, I don't see any reason to disallow them on either side. They're allowed around . too. Juerd
Re: Angle quotes and pointy brackets
On Tue, 30 Nov 2004 10:43:10 +0100, Juerd <[EMAIL PROTECTED]> wrote: Alexey Trofimenko skribis 2004-11-30 9:09 (+0300): delimiters should have corresponding closing character, so it should be something like Please, stop seeing ` as a circumfix operator in this context. What you do is like saying that after . you expect a capital letter. It's a programming language, and the only definition useful is the language itself, disregarding other languages, like Perl 5 and English. In current Perl, :: is also known as '. And that's not a quoting character in that context. In an early Apocalypse, Larry said not to make the same "mistake" again because it would be hard to syntax-colour. But that doesn't quite count, as matching for editors will have to be rewritten anyway to support things like "$foo{"bar"}". I have several editors even on windows, and not even specially written for perl, which do color ' as :: correctly. Personally, I liked that syntax, it has some similarities to Ireland surnames:) $O'Hara{Scarlett} but it puts big restrictions on what can be part of the name (actually, thoose which match to only), so $package'$varname won't work. I meant only that your ` can't be replacement to   because latter allows MUCH more freedom in key names. Actually, only space has special meaning here. so, could you be more explicit, what rules your syntax have? $a`$b+$c`$d, is it equivalent of $a[$b+$c][$d] or $a[$b]+$c[$d] ? and I think, polymorphic treating of ` as either {} or [] adds some overhead.. and unstability of your code. Especially in cases like $a`$b, when compiler just can't see in compiler time, what could be contained in $b - number or string. only one variant of that syntax looks for me useful: $var`Only`Ident`Compatible{$strings}`Here123 as replacement for $var{'Only'}{'Ident'}{'Compatible'}{$strings}{'Here123'} so ` works here exactly as Java(ECMA)Script . no spaces allowed, no expressions, and it is always a HASH subscript. doesn't lua have that prefix `Quoting behavior already? ( 'text' eq `text ) or it was some other language? If to mimic it, than $var`Only`Ident`Compatible{$strings}`Here123 could be automatiaclly transformed into $var'Only''Ident''Compatible'{$strings}'Here123' Macro definition for it could be very simple, like macro postfix:Â` is parsed {} {return "'$0'"} or something like. %hash"key""anotherkey"[1]=0 %hash'key''anotherkey'[1]=0 :key"value" :key'value' This is just making parens/curlies optional for more operators than <<>>. but :key'value' is the same as :key<>.. distinction shown only on occasional spaces in ''. $var.[1]. # yikes, but still better than <<>><<>> Still hard to type. Simply put, repeated circumfix operators suck, regardless of whether they are <>, <<>>, "", '', [], {}. hm, I thought something like this long time ago, when I come to perl and some other languages from pascal, where you could address a 3dimensional array with a[1,2,3] instead of a[1][2][3]; but there was no problem at all, it's a matter of habit. now I consider latter more readable and flexible.
Re: Angle quotes and pointy brackets
Alexey Trofimenko skribis 2004-11-30 9:09 (+0300): > delimiters should have corresponding closing character, so it should be > something like Please, stop seeing ` as a circumfix operator in this context. What you do is like saying that after . you expect a capital letter. It's a programming language, and the only definition useful is the language itself, disregarding other languages, like Perl 5 and English. In current Perl, :: is also known as '. And that's not a quoting character in that context. In an early Apocalypse, Larry said not to make the same "mistake" again because it would be hard to syntax-colour. But that doesn't quite count, as matching for editors will have to be rewritten anyway to support things like "$foo{"bar"}". > %hash`foo``bar`{$foo}[0]{$bar}=0 > or it would be *much* worse for parser than <>. Yes, that is indeed awful syntax. But fortunately, my proposal wasn't to use `` as a postcircumfix operator. > %hash"key""anotherkey"[1]=0 > %hash'key''anotherkey'[1]=0 > :key"value" > :key'value' This is just making parens/curlies optional for more operators than <<>>. >$var.[1]. # yikes, but still better than <<>><<>> Still hard to type. Simply put, repeated circumfix operators suck, regardless of whether they are <>, <<>>, "", '', [], {}. Juerd
Re: Angle quotes and pointy brackets
Juerd writes: > For oneliners, I think I'd appreciate using -o for that. The module > itself can be Perl::OneLiner. Things the module could do: > > * disable the default strict The C<-e> flag indicating the one-liner disables C anyway. Smylers
Re: Angle quotes and pointy brackets
Alexey Trofimenko writes: > But we have no need in qx either. Why to introduce (or REintroduce) > something if we have something similar already? > > $captured = system :capture q/cmd../; Or even calling the function C, as per Larry's April mail that Luke referenced. > I haven't that long unix background, and spawning processes is a very > *fat* operation for me.. maybe after year or two I'll change my point > of view, but for now I would be pretty happy with a 'slurp' variant. > IMHO, spawning processes has nothing to do with other quoters, and > perl already went far away from shells. I've got a sufficient Unix background that I find it awkward to use Windows, and I completely agree with you. Also, there are many instances of people using backticks or C when what they meant was C. Smylers
Re: Angle quotes and pointy brackets
On Fri, 26 Nov 2004 09:33:49 -0800, Larry Wall <[EMAIL PROTECTED]> wrote: On Fri, Nov 26, 2004 at 07:32:58AM +0300, Alexey Trofimenko wrote: : I notice that in Perl6 thoose funny  and  could be much more common : than other paired brackets. And some people likes how they look, but : nobody likes the fact that there's no (and won't!) be a consistent way to > : type them in different applications, wether it's hard or easy. ... : We also have another ascii pair, < and > . maybe they could be better : than  and  ?:) i'm not that farseeing, but isn't problem of : distinguishing < as a bracket and < as an comparison operator no harder : than distinguishing << as bracket and as part of heredoc?.. It would get very confusing visually, even if the computer could sort it out: @a >= @b @a >=< @b But there are some things that would be completely ambiguous: %hash %hash I not meant to replace it everywhere. But problem still exists. I know about only four uses of  and Â. Tell me if there's more? 1) hyperoperators; @a = @b Â* @c @aÂ.method @a = @b >>*<< @c @a>>.method (and, of course, mentioned in the past supercool 7-chars >>=:=<< operator!) hm.. IMO, hyperoperations are fat enough to be fat even in code. I wonder only if whitespace allowed there: @a = @b >> * << @c @a >>.method 2) qw//-like construct; @array = Âfoo bar baz @array = <> @array = qw once again, there's nothing wrong. Although, using just would confuse Perl6 no more than and confuses Perl5. "want an operator/want a term" rule applies here. 3) pair(adverb) value quoting; myfunc :fooÂbar :barÂbaz myfunc :arrayÂvalue1 value2 value3 myfunc :foo<> :bar<> # this certainly suck myfunc :foo("bar") :bar("baz") # I'm going to use that if it works(?). # still this suck less: myfunc :array<< value1 value2 value3 >> # ..than: myfunc :array("value1", "value2", "value3") but replacement of << >> with plain < > here is a no-problem: myfunc :foo :bar :array after you type :foo only three times, you'll acquire internal alarm on constructs like myfunc :foo :bar<10; which are rather obfuscating already. IMHO, mandatory whitespace between :bar and <10 here won't make anybody sick. I wonder how many people would like to write it myfunc:foo:bar<10; 4) hash subscripting; that's a real pain. rather cute $varÂkey1ÂÂkey2Â[3]Âkey3 suddenly becomes an ugly monster: $var<><>[3]<> of course we could write: $var{'key1'}{'key2'}[3]{'key3'} and I would prefer this one to previous variant.. but it adds noise too. and it prevent us to logicaly recognize 'key1' and 'key2' not as strings but as something more like struct elements, like we got used in perl5 When I look at this $var[3] then I think that it's a *very* cute, nice, and clean syntax... I really like it! (and I would sacrifice something for that to happen, if I would be Larry :) ) but there's a problem for people and parser too. < is a comparison *operator* and hash subscript is *operator* too, and there's no way to distinguish them at all. "Term rule" won't help here. +< and +> for comparison is plain sickness, of course. But we have some whitespace rules already. One of them is that subscripts shouldn't have whitespace to the left of them. We could add one more - to always PUT whitespace before < comparison. so $a Personally I'm not lazy to put spaces because of my little Forth experience. but I don't want to be lynched by mad horde of programmers in white robes, who will discover that while $a<$b {...} for qw {...} and even foo() *sigh.. I'll write my own grammar:) I only afraid that it would take a half of all my remaining lifetime (because of addiction) But I'll return to topic. I've seen proposal by Juerd, somewhere it this thread, to use `` for autoquoting subscripting. but proposed %hash`foo`bar`$foo`0`$bar=0 not going to work delimiters should have corresponding closing character, so it should be something like %hash`foo``bar`{$foo}[0]{$bar}=0 or it would be *much* worse for parser than <>. actually, (countrary to [] and {} which could have arbitrary complex nested expressions in it) "autoquoting" subscript shouldn't neccessarily be a paired string. Any character could be used for it without any ambiguity. Even perl4 style ' or even " Same with :pairs %hash"key""anotherkey"[1]=0 %hash'key''anotherkey'[1]=0 :key"value" :key'value' ah, using " here would cause difficulties to interpolation of "hello, $world" so what about ' or ` (or whatever you could imagine)? P.S. I also considered "shorcuts" like $var<>[1] # but that not going to remove MUCH of linenoise. or $var.[1]. # yikes, but still better than <<>><<>> ...
Re: Angle quotes and pointy brackets
Juerd <[EMAIL PROTECTED]> wrote: > > but talking about oneliners and short shell-like scripts, where `` is > > pretty useful.. hm.. things good for oneliners are rarely as good for > > larger programs, and vice versa. Of course, Perl5 proves opposite, but > > Perl6 tends to be a little more verbose, and even in Perl5 we use quite > > different "toolbox" and style for mentioned above. Why not to make an > > average sized module of various "shortcut" grammars, with a very short > > name ("x", f.e.), with defaults to export :all, so we could just do > > perl -Mx -e 'print `echo this is a perl5qx`' > > For oneliners, I think I'd appreciate using -o for that. The module > itself can be Perl::OneLiner. module e { module *::Main { # Or whatever we'd need to do to switch to the top-level Main close $*CODE;# if there is such a thing no strict; no warnings; my macro circumfix:<<` `>> (String $cmd) is parsed(/ <[^`\\]>* [ \\ . <[^`\\]>*: ] * /) { { run :capture $cmd } } use File::Copy qw(mv cp); ... # I do hope we get something better than #line. eval "#line 1 '-me'\n" ~ @ARGS.shift; } } perl -me 'say "This is my one-liner!"' One-liners with no specific support in the core--and it's different from Perl 5, so we can detect old one-liners. How's that for orthagonal? -- Brent 'Dax' Royal-Gordon <[EMAIL PROTECTED]> Perl and Parrot hacker "I might be an idiot, but not a stupid one." --c.l.p.misc (name omitted to protect the foolish)
Re: Angle quotes and pointy brackets
On Sat, 27 Nov 2004 11:36:14 +0100, James Mastros <[EMAIL PROTECTED]> wrote: Larry Wall wrote: Likewise a qw/a b/ is short for q:w/a b/ qw:q/a b/ $fromvar = 'foo bar'; qw:qq/a "something with spaces" b $fromvar/ # ?? -- slightly OT, but is that a, '"something', with, 'spaces"', # b, 'foo bar', or... um, what? Is qw smart enough to allow # internal quotes? Does splitting take place before or after # interpolation if it's interpolating? I like the idea that q would be the most general quoter, which could be used (with corresponding adverbs) instead of qq, qw, and heredoc, but qq and qw still exists in core as handy shortcuts for most frequent variants. something like (abstract) &qq ::= &q.assuming(:qq) (I don't know how to write it correctly - q isn't a function..) ... :s(0) adverb for specifying "interpolating level" for quoters seems kinda strange to me. First, it is harder to remember numbers than something symbolic. Second, there's going to be several interpolation layers, and some of them are independent of others, so having only one argument is insufficient. we would (not) want to interpolate: variables, functions, methods, \n \t and alike, backslashed delimiters backslashed backslashes ... and something also, i forgot what exactly:) and someone could want only some of the options.. "heredocness" should be just an adverb for all other type of quotes. personally I would be very glad to have "shell-like" quoting in qw, as James Mastros suggests above. It could save many keystrokes in definition of long lists where one occasional space-containing element happens to exist. some other cool variants: heredoc-qw which would see only \n as elements delimiter, and would strip leading and ending whitespace (for system) heredoc-qw for list of lists (\n as a row separator) heredoc-qq without ending "\n" I think, some interesting variants of scalars quoting could be borrowed from YAML(serialization language). think of folded scalars, #comments etc.. hmm.. maybe someone has ideas how to add custom behaviours for q without rewriting it? I mean, how to define custom :adverb for it..
Re: Angle quotes and pointy brackets
Alexey Trofimenko skribis 2004-11-30 3:17 (+0300): > but talking about oneliners and short shell-like scripts, where `` is > pretty useful.. hm.. things good for oneliners are rarely as good for > larger programs, and vice versa. Of course, Perl5 proves opposite, but > Perl6 tends to be a little more verbose, and even in Perl5 we use quite > different "toolbox" and style for mentioned above. Why not to make an > average sized module of various "shortcut" grammars, with a very short > name ("x", f.e.), with defaults to export :all, so we could just do > perl -Mx -e 'print `echo this is a perl5qx`' For oneliners, I think I'd appreciate using -o for that. The module itself can be Perl::OneLiner. Things the module could do: * introduce `` and qx * disable the default strict * enable warnings for things like open, print, close * introduce shortcuts like mv, cp, cd Juerd
Re: Angle quotes and pointy brackets
Matthew Walton wrote: James Mastros wrote: Larry Wall wrote: On Fri, Nov 26, 2004 at 07:32:58AM +0300, Alexey Trofimenko wrote: : ah, I forget, how could I do qx'echo $VAR' in Perl6? something like : qx:noparse 'echo $VAR' ? I think we need two more adverbs that add the special features of qx and qw, so that you could write that: q:x/echo $VAR/ where ordinary qx/$cmd/ is short for qq:x/$cmd/ I think I'd like that much better if we consider execution and word-splitting to be the primary operations, and interpolation and noninterpolation the adverbial modifiers then the other way around, making that qx:q/echo $VAR/ or qx:qq/$cmd/. especially because adverbs are meant to say "how to do" rather than "what to do", aren't they? OTOH, I expect backticks to be rare enough that I wouldn't mind writing use Spawn 'spawn'; spawn :capture :wait ($cmd); spawn :capture :wait ('echo $VAR'); Although I'm masochistic enough that I don't mind the idea of always having to do execution with qx//, qx:q// or qx:qq// (running with other suggestions, I'd guess that would be non-interpolating execution, then the same again more explicitly, then interpolating execution) but I do like the idea of spawn. hm.. qx:q// qx:qq// ...compare with: qx q// qx qq// so there's no need in adverbs. But we have no need in qx either. Why to introduce (or REintroduce) something if we have something similar already? $captured = system :capture q/cmd../; or maybe even: (code=>$code, out=>$captured, err=>$err) = system qq/cmd/; or maybe even(!) $captured = slurp qq/$cmd |/; Kind of removes the idea of pulling in the output of other programs as a fundamental part of the language though, for that it's nice to have an executing, capturing quote. Perhaps an adverb to qx that makes it behave like system() - I don't think it'd be a good idea to provide one that makes it behave like exec(), although perhaps other people do. I haven't that long unix background, and spawning processes is a very *fat* operation for me.. maybe after year or two I'll change my point of view, but for now I would be pretty happy with a 'slurp' variant. IMHO, spawning processes has nothing to do with other quoters, and perl already went far away from shells. but talking about oneliners and short shell-like scripts, where `` is pretty useful.. hm.. things good for oneliners are rarely as good for larger programs, and vice versa. Of course, Perl5 proves opposite, but Perl6 tends to be a little more verbose, and even in Perl5 we use quite different "toolbox" and style for mentioned above. Why not to make an average sized module of various "shortcut" grammars, with a very short name ("x", f.e.), with defaults to export :all, so we could just do perl -Mx -e 'print `echo this is a perl5qx`' even if `` would be taken for something more useful in Perl6, and still be able to import only something useful for our larger program with use x qw/:perl5qx/;
Re: Angle quotes and pointy brackets and heredocs
On Mon, Nov 29, 2004 at 01:56:59AM -0600, Rod Adams wrote: : What if instead, we add a different adverb to q// and qq//? something : like :h. That way people can mix and match all the quoting option they : want, and we remove some annoying requirements about when you can and : cannot have /<<\s+/ in your code. : : P5: : : print <<"END", " done.\n"; : line 1 : line 2 : END : : : P6: : : say qq:h/END/, "done."; : line 1 : line 2 : END I think I like it. Let me think about it some more though. Larry
Re: Angle quotes and pointy brackets and heredocs
Rod Adams skribis 2004-11-29 1:56 (-0600): > Are they really common enough to merit a "two char, absolutely no > whitespace after it" lexical? Especially one that looks a lot like the > left bitshift operator, as well as an ASCII version of a Unicode quoting > and splitting character? > What if instead, we add a different adverb to q// and qq//? something > like :h. That way people can mix and match all the quoting option they > want, and we remove some annoying requirements about when you can and > cannot have /<<\s+/ in your code. I think this is a very good idea. I too dislike the whitespace disambiguation thing for this, and was going to propose using unary % instead of <<. But this is even better, IMO. > Since < and > are now full class quote-like thingies in P6REs, much to > the chagrin of those of us who parse html on a regular basis, using them > as such in the rest of P6 makes sense as well. It would be great if <''> in a rule would be just ''. rule NotationDecl { <'[ | ] ? <'>'> } would then just be rule NotationDecl { ' [ | ] ? '>' } Which I find much easier to read. (Frankly, <'>'> is just too hard to type and be parsed by a human.) It also makes all other balanced delimiter matching rules more readable: rx/ \[ \w+ \] / rx/ <'['> \w+ <']'> / rx/ '[' \w+ ']' / Juerd
Re: Angle quotes and pointy brackets and heredocs
On Fri, Nov 26, 2004 at 07:32:58AM +0300, Alexey Trofimenko wrote: I notice that in Perl6 thoose funny « and » could be much more common than other paired brackets. And some people likes how they look, but nobody likes fact that there's no (and won't!) be a consistent way to type them in different applications, wether it's hard or easy. But to swap «» with [] or {} could be real shock for major part of people.. We also have another ascii pair, < and > . maybe they could be better than « and » ?:) i'm not that farseeing, but isn't problem of distinguishing < as a bracket and < as an comparison operator no harder than distinguishing << as bracket and as part of heredoc?.. Speaking of heredocs. Are they really common enough to merit a "two char, absolutely no whitespace after it" lexical? Especially one that looks a lot like the left bitshift operator, as well as an ASCII version of a Unicode quoting and splitting character? What if instead, we add a different adverb to q// and qq//? something like :h. That way people can mix and match all the quoting option they want, and we remove some annoying requirements about when you can and cannot have /<<\s+/ in your code. P5: print <<"END", " done.\n"; line 1 line 2 END P6: say qq:h/END/, "done."; line 1 line 2 END As for the topic being discussed, Since < and > are now full class quote-like thingies in P6REs, much to the chagrin of those of us who parse html on a regular basis, using them as such in the rest of P6 makes sense as well. Parsing should not be hindered since one would occur in operator context, and the other in expression context. -- Rod Adams
Re: Angle quotes and pointy brackets
John Macdonald skribis 2004-11-28 12:24 (-0500): > Doesn't that cause ambiguity between: > %hash{'foo'}{'bar'}{$foo}[0]{$bar} > and > %hash{'foo'}{'bar'}{$foo}{0}{$bar} > ^ ^ hash instead of subscript Not really. $hashref[] can't be used and $arrayref{} can't be used. This means Perl can easily disambiguate. Only for types that have both [] and {}, there is a problem. When they are both possible, just define one to have precedence. I'd pick {}. Exactly the same rule should apply for autovivification: {}. Juerd
Re: Angle quotes and pointy brackets
On Sun, Nov 28, 2004 at 12:24:08PM -0500, John Macdonald wrote: > On Sat, Nov 27, 2004 at 08:21:06PM +0100, Juerd wrote: > > James Mastros skribis 2004-11-27 11:36 (+0100): > > > Much more clear, saves ` for other things > > > > I like the idea. But as a earlier thread showed, people find backticks > > ugly. Strangely enough, only when used for something other than > > readpipe. > > > > The idea of being able to write > > > > %hash{'foo'}{'bar'}{$foo}[0]{$bar} > > > > as > > > > %hash`foo`bar`$foo`0`$bar > > > > still works very well for me. At least on all keyboards that I own, it > > is easier to type. And in all fonts that I use for terminals (that'd be > > only misc-fixed and 80x24 text terminals), it improves legibility too. > > Doesn't that cause ambiguity between: > > %hash{'foo'}{'bar'}{$foo}[0]{$bar} > and > %hash{'foo'}{'bar'}{$foo}{0}{$bar} > ^ ^ hash instead of subscript Hmm, I guess it is usually not ambiguous, only when it is causing auto-vivification of the hash-or-array with `0` is there an ambiguity between whether that means [0] and {'0'}. --
Re: Angle quotes and pointy brackets
On Sat, Nov 27, 2004 at 08:21:06PM +0100, Juerd wrote: > James Mastros skribis 2004-11-27 11:36 (+0100): > > Much more clear, saves ` for other things > > I like the idea. But as a earlier thread showed, people find backticks > ugly. Strangely enough, only when used for something other than > readpipe. > > The idea of being able to write > > %hash{'foo'}{'bar'}{$foo}[0]{$bar} > > as > > %hash`foo`bar`$foo`0`$bar > > still works very well for me. At least on all keyboards that I own, it > is easier to type. And in all fonts that I use for terminals (that'd be > only misc-fixed and 80x24 text terminals), it improves legibility too. Doesn't that cause ambiguity between: %hash{'foo'}{'bar'}{$foo}[0]{$bar} and %hash{'foo'}{'bar'}{$foo}{0}{$bar} ^ ^ hash instead of subscript --
Re: Angle quotes and pointy brackets
James Mastros wrote: Larry Wall wrote: On Fri, Nov 26, 2004 at 07:32:58AM +0300, Alexey Trofimenko wrote: : ah, I forget, how could I do qx'echo $VAR' in Perl6? something like : qx:noparse 'echo $VAR' ? I think we need two more adverbs that add the special features of qx and qw, so that you could write that: q:x/echo $VAR/ where ordinary qx/$cmd/ is short for qq:x/$cmd/ I think I'd like that much better if we consider execution and word-splitting to be the primary operations, and interpolation and noninterpolation the adverbial modifiers then the other way around, making that qx:q/echo $VAR/ or qx:qq/$cmd/. OTOH, I expect backticks to be rare enough that I wouldn't mind writing use Spawn 'spawn'; spawn :capture :wait ($cmd); spawn :capture :wait ('echo $VAR'); Much more clear, saves ` for other things, and allows for easy specification of the many adverbs of spawn (weather it returns the return status, the PID/FH set object, or output, if it waits right there, or runs in the background (and makes the return value lazy), if it replaces the current process (exec)... I'd quite like that. Although I think spawn should be a builtin rather than in a module, if it was in the core, and we were getting rid of backticks. Although I'm masochistic enough that I don't mind the idea of always having to do execution with qx//, qx:q// or qx:qq// (running with other suggestions, I'd guess that would be non-interpolating execution, then the same again more explicitly, then interpolating execution) but I do like the idea of spawn. Kind of removes the idea of pulling in the output of other programs as a fundamental part of the language though, for that it's nice to have an executing, capturing quote. Perhaps an adverb to qx that makes it behave like system() - I don't think it'd be a good idea to provide one that makes it behave like exec(), although perhaps other people do. qx:r/$cmd/ qx:s/$cmd/ # both of these give back return codes? Which one! But then qx:r:qq// might be messy. Or even qx:exitcode:interpolate// Ouch. This isn't very coherent, I'm just thinking out loud based on what other people have said that I like. But there are some things that would be completely ambiguous: %hash Bracketing operator. %hashVery long bracket operator, which quite likely has a syntax error directly after it. But might not have... there's a chance that could slip through, and I don't like that for some reason. : or maybe even we could see consistant to go after +<< +>> and alike, and : make old < and > written as +< and +> (and then lt and gt suddenly could : become ~< and ~> :) I think people would rise up and slay us if we did that. We're already getting sufficiently risen up and slain over Perl 6. Could be worse. They could rise from the grave and eat us! Who says they won't? Well, yes, but sometimes the weights change over time, so it doesn't hurt (much) to reevaluate occasionally. But in this case, I think I still prefer to attach the "exotic" characters to the exotic behaviors, and leave the angles with their customary uses. ...of which they have plenty already. Backtick has exactly one, and not an often-used one at that... I'm fine with axing it. Of course, there are a lot more people in the world then just me. I'm fine with it too. I use it a fair bit but I think it's important to have a very clear mark where you're going to an external program
Re: Angle quotes and pointy brackets
On Sat, 27 Nov 2004 10:28:28 -0800, Larry Wall <[EMAIL PROTECTED]> wrote: > On Fri, Nov 26, 2004 at 02:10:06PM -0800, Larry Wall wrote: > : I know everone has their reflexes tuned to type qw currently, but > : how many of you Gentle Readers would feel blighted if we turned it > : into q:w instead? > > Of course, if we wanted to really drive it into the ground, we could > turn qq// into q:q//, and then there's only one quoter. I'm sure if we > tried hard enough we could find someone this appeals to. You don't even have to look very far. This seems like a decent idea to me (although I won't be sad if it doesn't happen). > We also haven't quite detangled the backslash options. Seems there are > four levels of support (using \/ to stand for any terminator character): > > 0) none # <<'' default > 1) \\ and \/# q// default > 2) list # (nothing builtin) > 3) all # qq// default > > We need some way of specifying level 0 for a non-heredoc. We could turn > q// into that, I suppose. If we did, either we'd have to make '' the > same, or let it differ from q//, neither of which quite appeals to me, > but I might let myself be argued into one of them or the other. Actually, I'd like to see '' be a simple, completely raw quoting construct. But if we don't do that, we might be able to take a page out of C#'s book with @"" as the short form of the raw quoting construct. (Or something like that--I suspect C# picked @ because it's otherwise unused.) Actually, if we do something else with backticks, we can steal backticks for totally raw quoting... > I'm open to other ideas, though we must remind > ourselves that this is all very bike-sheddish. Oh, I vote for blue paint on that bike shed. -- Brent 'Dax' Royal-Gordon <[EMAIL PROTECTED]> Perl and Parrot hacker There is no cabal.
Re: Angle quotes and pointy brackets
James Mastros skribis 2004-11-27 11:36 (+0100): > Much more clear, saves ` for other things I like the idea. But as a earlier thread showed, people find backticks ugly. Strangely enough, only when used for something other than readpipe. The idea of being able to write %hash{'foo'}{'bar'}{$foo}[0]{$bar} as %hash`foo`bar`$foo`0`$bar still works very well for me. At least on all keyboards that I own, it is easier to type. And in all fonts that I use for terminals (that'd be only misc-fixed and 80x24 text terminals), it improves legibility too. Juerd
Re: Angle quotes and pointy brackets
Larry Wall wrote: On Fri, Nov 26, 2004 at 07:32:58AM +0300, Alexey Trofimenko wrote: : ah, I forget, how could I do qx'echo $VAR' in Perl6? something like : qx:noparse 'echo $VAR' ? I think we need two more adverbs that add the special features of qx and qw, so that you could write that: q:x/echo $VAR/ where ordinary qx/$cmd/ is short for qq:x/$cmd/ I think I'd like that much better if we consider execution and word-splitting to be the primary operations, and interpolation and noninterpolation the adverbial modifiers then the other way around, making that qx:q/echo $VAR/ or qx:qq/$cmd/. OTOH, I expect backticks to be rare enough that I wouldn't mind writing use Spawn 'spawn'; spawn :capture :wait ($cmd); spawn :capture :wait ('echo $VAR'); Much more clear, saves ` for other things, and allows for easy specification of the many adverbs of spawn (weather it returns the return status, the PID/FH set object, or output, if it waits right there, or runs in the background (and makes the return value lazy), if it replaces the current process (exec)... Likewise a qw/a b/ is short for q:w/a b/ qw:q/a b/ $fromvar = 'foo bar'; qw:qq/a "something with spaces" b $fromvar/ # ?? -- slightly OT, but is that a, '"something', with, 'spaces"', # b, 'foo bar', or... um, what? Is qw smart enough to allow # internal quotes? Does splitting take place before or after # interpolation if it's interpolating? : I notice that in Perl6 thoose funny « and » could be much more common : than other paired brackets. And some people likes how they look, but : nobody likes fact that there's no (and won't!) be a consistent way to type : them in different applications, wether it's hard or easy. : : But to swap «» with [] or {} could be real shock for major part of : people.. : We also have another ascii pair, < and > . maybe they could be better than : « and » ?:) i'm not that farseeing, but isn't problem of distinguishing < : as a bracket and < as an comparison operator no harder than distinguishing : << as bracket and as part of heredoc?.. It would get very confusing visually, even if the computer could sort it out: We could force whitespace disambugation, possibly -- require that <...> bracketing have whitespace on the outside and none on the inside. But that's ugly. But there are some things that would be completely ambiguous: %hash Bracketing operator. %hashVery long bracket operator, which quite likely has a syntax error directly after it. : or maybe even we could see consistant to go after +<< +>> and alike, and : make old < and > written as +< and +> (and then lt and gt suddenly could : become ~< and ~> :) I think people would rise up and slay us if we did that. We're already getting sufficiently risen up and slain over Perl 6. Could be worse. They could rise from the grave and eat us! Well, yes, but sometimes the weights change over time, so it doesn't hurt (much) to reevaluate occasionally. But in this case, I think I still prefer to attach the "exotic" characters to the exotic behaviors, and leave the angles with their customary uses. ...of which they have plenty already. Backtick has exactly one, and not an often-used one at that... I'm fine with axing it. Of course, there are a lot more people in the world then just me. If you're a White Russian I suppose the yolk is on me. In Russia, the yokes throw you! -=- James Mastros, theorbtwo
Re: Angle quotes and pointy brackets
On Fri, Nov 26, 2004 at 02:10:06PM -0800, Larry Wall wrote: : I might be happy to remove them, though people will write q:x instead : of qq:x and wonder why it doesn't interpolate. What I think is fun is : qq:x:w, which presumably runs the command and then splits the result : into words. : : I know everone has their reflexes tuned to type qw currently, but : how many of you Gentle Readers would feel blighted if we turned it : into q:w instead? Of course, if we wanted to really drive it into the ground, we could turn qq// into q:q//, and then there's only one quoter. I'm sure if we tried hard enough we could find someone this appeals to. We also haven't quite detangled the backslash options. Seems there are four levels of support (using \/ to stand for any terminator character): 0) none # <<'' default 1) \\ and \/# q// default 2) list # (nothing builtin) 3) all # qq// default We need some way of specifying level 0 for a non-heredoc. We could turn q// into that, I suppose. If we did, either we'd have to make '' the same, or let it differ from q//, neither of which quite appeals to me, but I might let myself be argued into one of them or the other. I figure :b can mean level 3, and for level 2 :b«nt» could mean just \n and \t. I suppose :b(0) and :b(1) could mean levels 0 and 1, but that's just plain sucky. Could force 0 and 1 with :b«» and :b«\\\/» respectively, but that's a bit long-winded. Could use two different adverbs, or a qh// that defaults to level 0, but those are also rather yucky. I'm open to other ideas, though we must remind ourselves that this is all very bike-sheddish. Larry
Re: Angle quotes and pointy brackets
On Fri, Nov 26, 2004 at 07:31:09PM +0100, Juerd wrote: : Larry Wall skribis 2004-11-26 9:33 (-0800): : > but that doesn't give you protection from other kinds of interpolation. : > I think we need two more adverbs that add the special features of qx and qw, : > so that you could write that: q:x/echo $VAR/ where ordinary qx/$cmd/ : > is short for qq:x/$cmd/ Likewise a qw/a b/ is short for q:w/a b/ : : With x and w as adverbs to q and qq, are qx and qw still worth keeping? : It's only one character less, qx isn't used terribly often and qw will : probably be written mostly as <<>> anyway. I might be happy to remove them, though people will write q:x instead of qq:x and wonder why it doesn't interpolate. What I think is fun is qq:x:w, which presumably runs the command and then splits the result into words. I know everone has their reflexes tuned to type qw currently, but how many of you Gentle Readers would feel blighted if we turned it into q:w instead? : And perhaps qq:x is a bit too dangerous. Suppose someone meant to type : qq:z[$foo] (where z is a defined adverb that does something useful to : the return value, but has no side effects) and mistypes it as : qq:x[$foo]. Instant hard-to-spot security danger. Seems rather unlikely. And presumably tainting should catch it if it's really a security issue. Larry
Re: Angle quotes and pointy brackets
Larry Wall skribis 2004-11-26 9:33 (-0800): > but that doesn't give you protection from other kinds of interpolation. > I think we need two more adverbs that add the special features of qx and qw, > so that you could write that: q:x/echo $VAR/ where ordinary qx/$cmd/ > is short for qq:x/$cmd/ Likewise a qw/a b/ is short for q:w/a b/ With x and w as adverbs to q and qq, are qx and qw still worth keeping? It's only one character less, qx isn't used terribly often and qw will probably be written mostly as <<>> anyway. And perhaps qq:x is a bit too dangerous. Suppose someone meant to type qq:z[$foo] (where z is a defined adverb that does something useful to the return value, but has no side effects) and mistypes it as qq:x[$foo]. Instant hard-to-spot security danger. Juerd
Re: Angle quotes and pointy brackets
On Fri, Nov 26, 2004 at 07:32:58AM +0300, Alexey Trofimenko wrote: : ah, I forget, how could I do qx'echo $VAR' in Perl6? something like : qx:noparse 'echo $VAR' ? Hmm, well, with the currently defined adverbs you'd have to say qx:s(0)'echo $VAR' but that doesn't give you protection from other kinds of interpolation. I think we need two more adverbs that add the special features of qx and qw, so that you could write that: q:x/echo $VAR/ where ordinary qx/$cmd/ is short for qq:x/$cmd/ Likewise a qw/a b/ is short for q:w/a b/ : (Note: I like thoose adverbs.. I could imagine that in Perl6 if you want : to have something done in some_other_way, you just should insert : :some_other_way adverb, and that is! perl will DWIM happily :) Well, that's perhaps a bit underspecified from the computer's point of view. : I notice that in Perl6 thoose funny « and » could be much more common : than other paired brackets. And some people likes how they look, but : nobody likes fact that there's no (and won't!) be a consistent way to type : them in different applications, wether it's hard or easy. : : But to swap «» with [] or {} could be real shock for major part of : people.. : We also have another ascii pair, < and > . maybe they could be better than : « and » ?:) i'm not that farseeing, but isn't problem of distinguishing < : as a bracket and < as an comparison operator no harder than distinguishing : << as bracket and as part of heredoc?.. It would get very confusing visually, even if the computer could sort it out: @a >= @b @a >=< @b But there are some things that would be completely ambiguous: %hash %hash> and alike, and : make old < and > written as +< and +> (and then lt and gt suddenly could : become ~< and ~> :) I think people would rise up and slay us if we did that. We're already getting sufficiently risen up and slain over Perl 6. : But I certain, Larry already weighted exact that solution years ago.. Well, yes, but sometimes the weights change over time, so it doesn't hurt (much) to reevaluate occasionally. But in this case, I think I still prefer to attach the "exotic" characters to the exotic behaviors, and leave the angles with their customary uses. : P.S. If you have an urgent need to throw spoiled eggs at me, consider all : above as very late or very early fools day joke.. or you could try, but : i've never heard about ballistic transcontinental eggs. If you're a White Russian I suppose the yolk is on me. Larry
Re: Angle quotes and pointy brackets
On Thu, 25 Nov 2004 13:45:51 -0800, Larry Wall <[EMAIL PROTECTED]> wrote: ... Hmm, I would say that "" is short for qq//, not qq"". Quote characters lose their identity when used with generalized quotes. (I realize this is not always true with Perl 5, but that can be construed as a mistake.) So  is not really short for qw unless you take the delimiters of the latter construct as simple characters without any  baggage, including the need to have a <<>> workaround. So I'd rather say  is short for qw//. ... ah, I forget, how could I do qx'echo $VAR' in Perl6? something like qx:noparse 'echo $VAR' ? (Note: I like thoose adverbs.. I could imagine that in Perl6 if you want to have something done in some_other_way, you just should insert :some_other_way adverb, and that is! perl will DWIM happily :) ... This approach doesn't help the person who can't even *display* ÂÂ, but that problem will be solved before the input problem is. For instance, PerlMonks has no problem displaying ÂÂ, but I haven't a clue how to type it into my browser yet. ... I notice that in Perl6 thoose funny  and  could be much more common than other paired brackets. And some people likes how they look, but nobody likes fact that there's no (and won't!) be a consistent way to type them in different applications, wether it's hard or easy. But to swap  with [] or {} could be real shock for major part of people.. We also have another ascii pair, < and > . maybe they could be better than  and  ?:) i'm not that farseeing, but isn't problem of distinguishing < as a bracket and < as an comparison operator no harder than distinguishing << as bracket and as part of heredoc?.. or maybe even we could see consistant to go after +<< +>> and alike, and make old < and > written as +< and +> (and then lt and gt suddenly could become ~< and ~> :) But I certain, Larry already weighted exact that solution years ago.. P.S. If you have an urgent need to throw spoiled eggs at me, consider all above as very late or very early fools day joke.. or you could try, but i've never heard about ballistic transcontinental eggs.
Re: Angle quotes and pointy brackets
Larry Wall writes: > PerlMonks has no problem displaying «», but I haven't a clue how to > type it into my browser yet. If your browser is using Gnome then holding down Ctrl+Shift while typing AB (for «) or BB (for ») might work. (This is also working for me typing this in 'Vim' in a 'Gnome Terminal', but isn't as nice as the 'Vim' digraphs.) Smylers
Re: Angle quotes and pointy brackets
On Thu, Nov 25, 2004 at 11:12:32PM +0100, Juerd wrote: : But if mixed «>> is allowed, isn't that «<<»syntax error? Or did I : misinterpret the answer re mixing them? Uh, I wasn't aware that I'd actually answered the question. :-) My actual inclination is to disallow it. I was just trying to argue myself out of that position. Bad habit of mine, thinking out loud. : > my macro circumfix:«<< >>» is gone; : : Perhaps "is gone" is a bit too easy for something that shouldn't be : done. Okay, make it "is obliterated_after_grave_consideration_of_the_consequences". Larry
Re: Angle quotes and pointy brackets
Larry Wall skribis 2004-11-25 13:45 (-0800): > Hmm, I would say that "" is short for qq//, not qq"". Quote characters > lose their identity when used with generalized quotes. (I realize this > is not always true with Perl 5, but that can be construed as a mistake.) > So «» is not really short for qw«» unless you take the delimiters of the > latter construct as simple characters without any «» baggage, including > the need to have a <<>> workaround. So I'd rather say «» is short for qw//. I'm happy to read this. Perl 5's semantics with qx|m|qr|s and '' probably made me translate "" to qq"" instead of qq//, or qq{} as perlop lists it. > : But as « foo bar » and << foo bar >> are the same thing, I wonder what > : qw<< foo bar >> means. Is that qw/< foo bar >/ or is that qw/foo bar/? > : And is this consistent with other operators, i.e. rx«» versus rx<<>>? > It means qw/< foo bar>/, and yes, that's consistent. That's a relief :) > This approach doesn't help the person who can't even *display* «», but > that problem will be solved before the input problem is. For instance, > PerlMonks has no problem displaying «», but I haven't a clue how to type > it into my browser yet. Should you happen to use X with the Xkb extension, it is a matter of assigning a key to Multi_key and then typing Multi_key < <. I have assigned my rightmost "Windows key" (the "Menu" key) with: xmodmap -e "keysym Menu = Multi_key" > So you want to violate Liskov substitutability on grammars, eh? :-) I'd even violate gravity, if I could! > While one can certainly redefine rule methods to pitch a fit if called, > the real way you cut down the language is by not referring to those > rules in the first place from elsewhere. Which means you have to override > those referring rules, after which it almost doesn't matter if the > previously referred to rules are somehow cancelled or not. I was afraid that that'd be the answer. > The other part of it is that some of the constructs are catalogued in > hashes and arrays rather than in rule alternatives. When you derive > a grammar you can certainly copy over a part of the hash or array and > leave out other parts. These hashes and arrays are loaded up in the > first place via the various syntactic categories we go on about. So > maybe we have some way of cancelling syntax. That's better news :) > BEGIN { undef &circumfix:«<< >>»; } But if mixed «>> is allowed, isn't that «<<»syntax error? Or did I misinterpret the answer re mixing them? > my macro circumfix:«<< >>» is gone; Perhaps "is gone" is a bit too easy for something that shouldn't be done. Juerd
Re: Angle quotes and pointy brackets
On Thu, Nov 25, 2004 at 09:55:54PM +0100, Juerd wrote: : As we now know, in many situations, << and « mean the same thing. In : exactly those situations, the same is true for >> and ». However, : sometimes, « cannot be used where << can. Here-docs are an example. : : «» (or <<>>, if you wish) quotes. I am assuming that «» is a shorthand : for qw«», except where special syntax is used with hash slices and : :-pairs, just like //, which is short for m//, "" for qq"", etcetera. Hmm, I would say that "" is short for qq//, not qq"". Quote characters lose their identity when used with generalized quotes. (I realize this is not always true with Perl 5, but that can be construed as a mistake.) So «» is not really short for qw«» unless you take the delimiters of the latter construct as simple characters without any «» baggage, including the need to have a <<>> workaround. So I'd rather say «» is short for qw//. : But as « foo bar » and << foo bar >> are the same thing, I wonder what : qw<< foo bar >> means. Is that qw/< foo bar >/ or is that qw/foo bar/? : And is this consistent with other operators, i.e. rx«» versus rx<<>>? It means qw/< foo bar>/, and yes, that's consistent. : Another question comes to mind as I am typing this message. Can « and >> : be used together, or does « always need » and << need >>? If a matching : pair is required, then does the same hold true for vector ops with anqle : quotes on both sides (i.e. is that seen as a "quoted" operator, or as an : operator that happens to have two vectorizing symbols)? I don't see that it's terribly important either to allow that or to disallow it. I do think we should discourage asymmetry, but I can well imagine that someone who doesn't have easy «» access might end up replacing one end without replacing the other. It should be easy for someone in this fix to translate the line to the «» form. Perhaps perl itself ought to offer to do the translation for you. Basically, the sooner we can get code into a canonical form, the less trouble we'll have overall. This approach doesn't help the person who can't even *display* «», but that problem will be solved before the input problem is. For instance, PerlMonks has no problem displaying «», but I haven't a clue how to type it into my browser yet. Some people might actually prefer to have the <<>> form illegal, not because they don't want to type it in that way, but because they want to be forced to translate to «» before the semi-bogus <<>> forms enter The Record. : One last question for now: how hard will it be to implement a grammar : with certain not otherwise specified language features *removed*? So you want to violate Liskov substitutability on grammars, eh? :-) While one can certainly redefine rule methods to pitch a fit if called, the real way you cut down the language is by not referring to those rules in the first place from elsewhere. Which means you have to override those referring rules, after which it almost doesn't matter if the previously referred to rules are somehow cancelled or not. The other part of it is that some of the constructs are catalogued in hashes and arrays rather than in rule alternatives. When you derive a grammar you can certainly copy over a part of the hash or array and leave out other parts. These hashes and arrays are loaded up in the first place via the various syntactic categories we go on about. So maybe we have some way of cancelling syntax. BEGIN { undef &circumfix:«<< >>»; } or maybe even: my macro circumfix:«<< >>» is gone; That would have the effect of removing the '<<' key from the term hash, or for a lexical declaration, making a copy of the term hash without that key, so that when we hit the end of this lexical scope. we can restore the old hash. Larry
Re: Angle quotes and pointy brackets
Juerd writes: > As we now know, in many situations, << and « mean the same thing. In > exactly those situations, the same is true for >> and ». However, > sometimes, « cannot be used where << can. Here-docs are an example. Why can't « be used for here-docs? I thought Larry had said they were completely interchangeable. > But as « foo bar » and << foo bar >> are the same thing, I wonder what > qw<< foo bar >> means. Is that qw/< foo bar >/ or is that qw/foo bar/? I'd hope it's the former -- that is, that « can be substituted for << anywhere that << is a single operator, not just somewhere that those two characters happen to be adjacent to each other in the source, and » likewise. Otherwise you could have ridiculous things like: m>foo>>0 which parses as: m/foo/ > 0 being written as: m>foo»0 And that's blatantly of no use to anybody. Smylers