Re: String Literals, take 1
[email protected] ("Joseph Ryan") Sun, 01 Dec 2002 06:49:42 +0000
| Newsgroups | perl.perl6.documentation |
|---|---|
| Message-ID | <[email protected]> |
(* Note: Please reply to [email protected] *) (* Don't reply to this hotmail address! I'm deleting it tomarrow! *) (* Fight the urge! *) >: Jonathan Scott Duff <[email protected]> >>: Joseph Ryan <[email protected]> > > Anyways, here's a first draft of the string documentation ... > >I didn't see any mention of vstrings (e.g. tokens of the form >v5.8.0. I also got the impression from a response Larry made to one >of the emails in the thread on numbers that the leading v might be >optional) Good point, I missed them; interestingly, I can't find a reference to them in perl5's perlop. > >Also, I didn't see mention of the string context coercer which though >it doesn't really have to do with literals, probably should have a >reference here somewhere. I disagree, that should go in perlop. (Same with the concat operator, whatever that will be when that section is written) > > > - Larry was never specific as to how hashes interpolate; anyone have > > any ideas? > >I'd think that hashes would interpolate as a list of >key,value,key,value,etc. > >BTW, how do pairs interpolate? A hash is a set of pairs, so pair interpolation needs to be defined before hash interpolation can. I like the way the RFC suggests that hashes interpolate, given that $/ and $" are upgraded to perl6 terms. > > > =pod > > > > =head1 Strings > > > > A string is a literal value that represents a sequence of characters. > > A string object is formed when a sequence of characters is enclosed in > > one of the quoting operators, of which there are 3 types: > > Interpolating, Non-Interpolating, and Here-Docs; > >This classification doesn't make sense to me. Here-docs are just another >quoting operator which can be interpolating or non-interpolating.. Yes, thats true, but Here-Docs are so... different. Different enough to get their own section. You are right that the sentance is unclear, however. > >Also, the whole idea of "interpolation" probably needs to be >explained up front. Maybe something like this: > > There are two types of quoting operators: interpolating and > non-interpolating. In interpolating constructs, the value of a > variable is substituted for the variable name within the string > and certain characters have special meaning when preceded by a > backslash (C<\>). In non-interpolating constructs, a variable > name that appears within the string is used as-is. The simplest > examples of these two types of quoting operators are strings > delimited by double (interpolating) and single quotes > (non-interpolating). For example: > > 'The quick brown $animal' > "The quick brown $animal" > > In the first string, perl will take each character literally and > perform no special processing. In the second string, the value > of the variable $animal is inserted within the string at that > location. If $animal had had the value "fox", then the second > string would have become "The quick brown fox". > > More on the various quoting operators below. > Sounds good to me, except that the backslash is special in single-quoted strings too. The only real non-interpolated construct is the single- quoted Here-Doc. > > =head2 Non-Interpolating Constructs > >oh, a minor nit here ... tackle the items in the order that you first >list them. In your 3 type classification you mention interpolating >first then non-interpolating, so you should start off talking about >interpolating or switch the order in the list. Woops. :) Joseph F. Ryan. _________________________________________________________________ STOP MORE SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail