Re: String interpolation

2004-07-27 Thread Jonathan Scott Duff
On Tue, Jul 27, 2004 at 12:44:09PM +0200, Michele Dondi wrote: > On Sat, 24 Jul 2004, Larry Wall wrote: > > > This particular modeful behavior is easily handled by most current > > editors. You have to be able to treat the insides of strings different > > from the outsides. That being said, ther

Re: String interpolation

2004-07-27 Thread Michele Dondi
On Sat, 24 Jul 2004, Larry Wall wrote: > This particular modeful behavior is easily handled by most current > editors. You have to be able to treat the insides of strings different > from the outsides. That being said, there are plenty of other things > in Perl 6 already that will drive editors

Re: String interpolation

2004-07-27 Thread Michele Dondi
On Sat, 24 Jul 2004, Jonadab the Unsightly One wrote: > > As a related side note, is it possible to use multi-char delimiters in > > Perl6? I mean, a la: > > > > qq<<...>>; > > I would worry that you'd be getting "<" and ">" at the beginning and > end of your string. IMO, there are enough cha

Re: String interpolation

2004-07-26 Thread James Mastros
David Green wrote: I was also going to say something tongue-in-cheek about Unicode quotation marks, but curly-quotes could actually be quite useful. Reasons not to use them as anything but synonyms for normal double quotes: 1) They look too much like each-other. 2) They look too much like normal

Re: String interpolation

2004-07-26 Thread David Green
On 7/21/04, Brent 'Dax' Royal-Gordon wrote: >Amen. Please don't steal unnecessary metacharacters in qq() >strings--although I still think we should keep it, @ causes a lot of >problems. That's why my suggestion would be to use a character that already has a special meaning in double-quoted st

Re: String interpolation

2004-07-26 Thread Piers Cawley
Damian Conway <[EMAIL PROTECTED]> writes: > I can't say I'm keen on making {...} special in strings. I felt that the > $(...) and @(...) were a much cleaner and more general solution. The > prospect of backslashing every opening brace in every interpolated > string is not one I relish. Maybe we co

Re: String interpolation

2004-07-26 Thread Piers Cawley
Larry Wall <[EMAIL PROTECTED]> writes: > On Tue, Jul 20, 2004 at 11:00:39PM -0700, chromatic wrote: > : On Tue, 2004-07-20 at 19:35, Luke Palmer wrote: > : > : > The New Way (tm) to do that would probably be sticking a role onto the > : > array object with which you're dealing: > : > > : > m

Re: String interpolation

2004-07-24 Thread Larry Wall
On Thu, Jul 22, 2004 at 08:23:21AM +0200, Juerd wrote: : Larry Wall skribis 2004-07-21 12:25 (-0700): : > I'm inclining more towards the "only interpolate things that end with : > brackets or parens" rule. That would allow $foo.bar() to interpolate, : > but not $foo.bar. : : Anything that is deci

Re: String interpolation

2004-07-24 Thread Larry Wall
On Thu, Jul 22, 2004 at 03:33:01PM +0200, Michele Dondi wrote: : But then an interesting point, and one that has already : been raised, is that it should be somehow possible to customize string : interpolation bu means of e.g. adverbs (fortunately we don't have "true" : literal strings but rather

Re: String interpolation

2004-07-24 Thread Larry Wall
On Thu, Jul 22, 2004 at 11:12:16PM +0100, Dave Mitchell wrote: : On Wed, Jul 21, 2004 at 04:37:29PM -0700, Larry Wall wrote: : > We allowed/required @foo to interpolate in Perl 5, and it catches a : > certain number of people off guard regularly, including yours truly. : > So I can argue [EMAIL PRO

Re: String interpolation

2004-07-24 Thread Larry Wall
On Thu, Jul 22, 2004 at 11:16:09AM -0500, Dan Hursh wrote: : Larry Wall wrote: : >No Yes : >-- --- : >@foo@foo[1] : >%bar%bar{"a"} or %bar«a» : >$foo.bar$foo.bar() : >&foo &foo(1) : : I may have missed it, but what are the contexts

Re: String interpolation

2004-07-24 Thread Larry Wall
On Sat, Jul 24, 2004 at 11:59:30AM -0400, Jonadab the Unsightly One wrote: : : Correct me if I'm wrong, but, by analogy with $foo.bar(), ... : : > No Yes : > -- --- : > @foo@foo[1] : > %bar%bar{"a"} or %bar«a» : > $foo.bar$foo.bar() : >

Re: String interpolation

2004-07-24 Thread Larry Wall
On Sat, Jul 24, 2004 at 12:08:24PM -0400, Jonadab the Unsightly One wrote: : Johan Vromans <[EMAIL PROTECTED]> writes: : : > Larry Wall <[EMAIL PROTECTED]> writes: : > : >> : my $d="a"; : >> : print "--$d--{my $d = "b" }--$d--\n"; : >> : >> Yes, that is correct. : > : > I'm afraid things like th

Re: String interpolation

2004-07-24 Thread Jonadab the Unsightly One
Johan Vromans <[EMAIL PROTECTED]> writes: > Larry Wall <[EMAIL PROTECTED]> writes: > >> : my $d="a"; >> : print "--$d--{my $d = "b" }--$d--\n"; >> >> Yes, that is correct. > > I'm afraid things like this will keep many popular editors and IDEs > from implementing perl6 support... Then maybe peo

Re: String interpolation

2004-07-24 Thread Jonadab the Unsightly One
Correct me if I'm wrong, but, by analogy with $foo.bar(), ... > No Yes > -- --- > @foo@foo[1] > %bar%bar{"a"} or %bar«a» > $foo.bar$foo.bar() > &foo&foo(1) @foo@foo.join(" ") Yes? /me idly wonders whether map an

Re: String interpolation

2004-07-24 Thread Jonadab the Unsightly One
Michele Dondi <[EMAIL PROTECTED]> writes: > Well, it seems that there's still a big confusion/indecision about > the default behaviour. But then an interesting point, and one that > has already been raised, is that it should be somehow possible to > customize string interpolation bu means of e.g.

Re: String interpolation

2004-07-22 Thread David Storrs
On Wed, Jul 21, 2004 at 04:37:29PM -0700, Larry Wall wrote: > No Yes > -- --- > @foo@foo[1] > %bar%bar{"a"} or %bar«a» > $foo.bar$foo.bar() > &foo &foo(1) > > In this worldview, $foo is an exception only because it doesn't natural

Re: String interpolation

2004-07-22 Thread Dan Hursh
Larry Wall wrote: No Yes -- --- @foo@foo[1] %bar%bar{"a"} or %bar«a» $foo.bar$foo.bar() &foo&foo(1) I may have missed it, but what are the contexts in these cases? I'm thinking the first two are easily scalar. Are the second list

Re: String interpolation

2004-07-22 Thread Dave Mitchell
On Wed, Jul 21, 2004 at 04:37:29PM -0700, Larry Wall wrote: > We allowed/required @foo to interpolate in Perl 5, and it catches a > certain number of people off guard regularly, including yours truly. > So I can argue [EMAIL PROTECTED] both ways. Currently @foo[] is a syntax error. maybe "@foo[]"

Re: String interpolation

2004-07-22 Thread Aldo Calpini
Jonathan Scott Duff wrote: Surely you mean [EMAIL PROTECTED] instead of 0..Inf I think the iterator implicit in array slicing should, and could, be smart enough to return when there's nothing more to iterate. Considering the following code: @foo = (1, 2, 3); @bar = @foo[1..Inf]; @bar should

Re: String interpolation

2004-07-22 Thread Michele Dondi
On Tue, 20 Jul 2004, Damian Conway wrote: > Larry wrote: > > > Actually, I've been rethinking this whole mess since last week, and > > am seriously considering cranking up the Ruby-o-meter here just a tad. [snip] > I can't say I'm keen on making {...} special in strings. I felt that the > $(...)

Re: String interpolation

2004-07-22 Thread Juerd
Matt Diephouse skribis 2004-07-20 20:06 (-0400): > This is close to the new form() syntax as well, which could be > considered a plus. I for one won't complain about adding the good things > from Ruby back in to Perl. Ehm, no, that means that if you want to interpolate something into the format

Re: String interpolation

2004-07-22 Thread Johan Vromans
Larry Wall <[EMAIL PROTECTED]> writes: > : my $d="a"; > : print "--$d--{my $d = "b" }--$d--\n"; > > Yes, that is correct. I'm afraid things like this will keep many popular editors and IDEs from implementing perl6 support... -- Johan

Re: String interpolation

2004-07-22 Thread Matt Diephouse
Larry Wall wrote: Actually, I've been rethinking this whole mess since last week, and am seriously considering cranking up the Ruby-o-meter here just a tad. At the moment I'm inclined to say that the *only* interpolators in double quotes are: \n, \t etc. $foo @foo[$i] %foo{$k} {

Re: String interpolation

2004-07-21 Thread Juerd
Larry Wall skribis 2004-07-21 12:25 (-0700): > I'm inclining more towards the "only interpolate things that end with > brackets or parens" rule. That would allow $foo.bar() to interpolate, > but not $foo.bar. Anything that is decided by something's end makes things hard to read, hard to learn and

Re: String interpolation

2004-07-21 Thread David Manura
Two points, if I may jump in here: (1) If the interpolation rule is to be simple as suggested, why not impose this rule: "A character (except for a backslash) is interpreted literally if it is not preceeded by a backslash." For example, "The value is \$foo.bar()." --> "The value is 3." "T

Re: String interpolation

2004-07-21 Thread Luke Palmer
Uri Guttman writes: > LW> : so method calls would need the $() or @() wrappers as do all expressions > LW> : beyond simple scalar value lookup. that means $foo, @foo[0], $foo[0], > LW> : %foo{'bar'} and $foo{'bar'} all interpolate and only their variants > LW> : (longer index/key expression

Re: String interpolation

2004-07-21 Thread Brent 'Dax' Royal-Gordon
Uri Guttman wrote: how would you put in the literal string $foo.bar()? escaping the . or the ( ? The dollar sign. (Or, if you wanted to interpolate $foo while leaving the .bar() intact, I would imagine that either \. or \( would suffice.) -- Brent "Dax" Royal-Gordon <[EMAIL PROTECTED]> Perl and

Re: String interpolation

2004-07-21 Thread Uri Guttman
> "LW" == Larry Wall <[EMAIL PROTECTED]> writes: LW> On Tue, Jul 20, 2004 at 08:42:48PM -0400, Uri Guttman wrote: LW> Many expressions are naturally scalar even in list context. Most LW> operators force scalar context unless you hyper them. In particular, LW> the new unary operators

Re: String interpolation

2004-07-21 Thread Larry Wall
On Wed, Jul 21, 2004 at 11:06:55PM +0200, Juerd wrote: : Larry Wall skribis 2004-07-21 10:24 (-0700): : > Interpolates : > NoYes : > ----- : > @foo @foo[1] : > %bar %bar{"a"} : > $foo.bar $foo.bar() : : Oh, please don't do that. : : Whatever inte

Re: String interpolation

2004-07-21 Thread Larry Wall
On Thu, Jul 22, 2004 at 12:31:08AM +0400, Alexey Trofimenko wrote: : I used $d='b' ,and not $d="b" above, just because it should be $d=\"b\" : yes, I know, perl5 parser makes several passes on quotes, and when it sees : open quote, it finds closing quote first, then parses all inside. : AFAIK, pe

Re: String interpolation

2004-07-21 Thread Juerd
Larry Wall skribis 2004-07-21 10:24 (-0700): > Interpolates > NoYes > ----- > @foo @foo[1] > %bar %bar{"a"} > $foo.bar $foo.bar() Oh, please don't do that. Whatever interpolation thing is invented, make it SIMPLE. Allowing @foo[1]

Re: String interpolation

2004-07-21 Thread Alexey Trofimenko
On Wed, 21 Jul 2004 10:21:58 -0700 (PDT), Austin Hastings <[EMAIL PROTECTED]> wrote: --- Larry Wall <[EMAIL PROTECTED]> wrote: If {...} supplies list context by default, most intepolations are either the same length or shorter: $($foo) {$foo} @(@foo) [EMAIL PROTECTED] $(@foo)

Re: String interpolation

2004-07-21 Thread Jonathan Scott Duff
On Wed, Jul 21, 2004 at 12:39:57PM -0600, Luke Palmer wrote: > Jonathan Scott Duff writes: > > On Wed, Jul 21, 2004 at 07:35:08PM +0200, Aldo Calpini wrote: > > > Larry Wall wrote: > > > > > > >Hmm. That makes me wonder what the slice notation for "everything" is. > > > > > > > > > > > maybe @fo

Re: String interpolation

2004-07-21 Thread Larry Wall
On Tue, Jul 20, 2004 at 08:42:48PM -0400, Uri Guttman wrote: : and how do you force scalar context without a scalar() or $() wrapper : around the expression in {}? hard to say whether scalar or list context : is more popular and so would get the huffman prize. i liked @() and $() : for both context

Re: String interpolation

2004-07-21 Thread Brent 'Dax' Royal-Gordon
Luke Palmer wrote: I suppose another good thing is that it makes unneccesary the balanced brace rule in qq{} that was there in Perl 5: all braces need to be backwhacked now. However, all braces need to be backwhacked now. Ugh. I was dreading code-generating heredocs, but with the inclusion of \qq[

Re: String interpolation

2004-07-21 Thread Larry Wall
On Wed, Jul 21, 2004 at 12:36:51PM -0600, Luke Palmer wrote: : Brent 'Dax' Royal-Gordon writes: : > The equivalent regex syntax isn't interpolating, even to the extent that : > a bare $foo or @bar is, so this would be sort of a "false cognate"--IMHO : > another reason not to have interpolating {}.

Re: String interpolation

2004-07-21 Thread Luke Palmer
Jonathan Scott Duff writes: > On Wed, Jul 21, 2004 at 07:35:08PM +0200, Aldo Calpini wrote: > > Larry Wall wrote: > > > > >Hmm. That makes me wonder what the slice notation for "everything" is. > > > > > > > > maybe @foo[..] (a short form for @foo[0..Inf]) ? > > Surely you mean [EMAIL PROTECTE

Re: String interpolation

2004-07-21 Thread Luke Palmer
Brent 'Dax' Royal-Gordon writes: > Luke Palmer wrote: > >I admit there's a certain interest to Larry's new idea. I've been > >looking for more distinction between $, @, and % in Perl 6, since they > >start to become mostly irrelavent. In the new proposal: > > > >my @a = (1,2,3,4,5); > >my

Re: String interpolation

2004-07-21 Thread Larry Wall
On Wed, Jul 21, 2004 at 07:35:08PM +0200, Aldo Calpini wrote: : Larry Wall wrote: : : >Hmm. That makes me wonder what the slice notation for "everything" is. : > : > : maybe @foo[..] (a short form for @foo[0..Inf]) ? %foo{..} should also be : allowed, of course (which : unfortunately is not a s

Re: String interpolation

2004-07-21 Thread Jonathan Scott Duff
On Wed, Jul 21, 2004 at 07:35:08PM +0200, Aldo Calpini wrote: > Larry Wall wrote: > > >Hmm. That makes me wonder what the slice notation for "everything" is. > > > > > maybe @foo[..] (a short form for @foo[0..Inf]) ? Surely you mean [EMAIL PROTECTED] instead of 0..Inf > %foo{..} should also b

Re: String interpolation

2004-07-21 Thread Larry Wall
On Tue, Jul 20, 2004 at 11:00:39PM -0700, chromatic wrote: : On Tue, 2004-07-20 at 19:35, Luke Palmer wrote: : : > The New Way (tm) to do that would probably be sticking a role onto the : > array object with which you're dealing: : > : > my @foo does separator('//') = (1,2,3,4,5); : > say

Re: String interpolation

2004-07-21 Thread Aldo Calpini
Larry Wall wrote: Hmm. That makes me wonder what the slice notation for "everything" is. maybe @foo[..] (a short form for @foo[0..Inf]) ? %foo{..} should also be allowed, of course (which unfortunately is not a short form for 0..Inf). or perhaps, with a slight analogy with filesystems, @foo[*

Re: String interpolation

2004-07-21 Thread Larry Wall
On Wed, Jul 21, 2004 at 01:13:29PM -0400, Mark J. Reed wrote: : On 2004-07-21 at 09:42:44, Larry Wall wrote: : > Plus it ignores the fact that we've already introduced single character : > scalar context operators that make it trivial to coerce from list : > context to scalar. If {...} supplies li

Re: String interpolation

2004-07-21 Thread Larry Wall
On Tue, Jul 20, 2004 at 08:35:10PM -0600, Luke Palmer wrote: : This doesn't quite feel right to me. I was really a big fan of the good : ol' Perl 6 days where you could interpolate as in Perl 5, and method : calls required parentheses. I understand why Larry wanted to take out : the parentheses,

Re: String interpolation

2004-07-21 Thread Austin Hastings
--- Larry Wall <[EMAIL PROTECTED]> wrote: > If {...} supplies list context by default, most > intepolations are either the same length or shorter: > > $($foo) {$foo} > @(@foo) [EMAIL PROTECTED] > $(@foo) [EMAIL PROTECTED] > [EMAIL PROTECTED] > [EMAIL

Re: String interpolation

2004-07-21 Thread Mark J. Reed
On 2004-07-21 at 09:42:44, Larry Wall wrote: > Plus it ignores the fact that we've already introduced single character > scalar context operators that make it trivial to coerce from list > context to scalar. If {...} supplies list context by default, most > intepolations are either the same length

Re: String interpolation

2004-07-21 Thread Larry Wall
On Wed, Jul 21, 2004 at 06:25:46AM +0400, Alexey Trofimenko wrote: : some questions: : : 1) is "@a[1][2]{'a'}«b»" interpolateable? Yes. : and what about "@a[1]('arg')[3]"? I can argue that both ways, but overall it seems like it won't cause much of a problem, and keeps () in the same mental cat

Re: String interpolation

2004-07-21 Thread Larry Wall
On Tue, Jul 20, 2004 at 09:20:56PM -0400, Damian Conway wrote: : So what about: : : $foo[$i] : $foo{$k} : : ??? Those would work. : And would slices interpolate? Yes. Slices are entirely determined by what's in the subscript. : I can't say I'm keen on making {...} special in stri

Re: String interpolation

2004-07-21 Thread Dave Whipp
"Chromatic" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Shh, no one's let slip the idea of curried roles yet! I'm not even > certain A12 mentioned parametric roles, let alone first-class roles. And with parametric roles, perhaps we also get C roles? Dave.

Re: String interpolation

2004-07-21 Thread Dave Whipp
"Brent 'Dax' Royal-Gordon" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Amen. Please don't steal unnecessary metacharacters in qq() > strings--although I still think we should keep it, @ causes a lot of > problems. I seem to recall an issue, last week, of whether adverbs can be a

Re: String interpolation

2004-07-21 Thread Brent 'Dax' Royal-Gordon
Luke Palmer wrote: I admit there's a certain interest to Larry's new idea. I've been looking for more distinction between $, @, and % in Perl 6, since they start to become mostly irrelavent. In the new proposal: my @a = (1,2,3,4,5); my $a = @a; say "@a"; # @a say "$a"; # 1

Re: String interpolation

2004-07-20 Thread chromatic
On Tue, 2004-07-20 at 19:35, Luke Palmer wrote: > The New Way (tm) to do that would probably be sticking a role onto the > array object with which you're dealing: > > my @foo does separator('//') = (1,2,3,4,5); > say "[EMAIL PROTECTED]"; # 1//2//3//4//5 Shh, no one's let slip the idea

Re: String interpolation

2004-07-20 Thread Luke Palmer
Alexey Trofimenko writes: > On Tue, 20 Jul 2004 16:06:40 -0700, Larry Wall <[EMAIL PROTECTED]> wrote: > >So all of these would require curlies: > > > >{foo()} > >[EMAIL PROTECTED] > >... > > ah.. how poorly.. and how sufficient!.. But it's.. it's just not quite > like in perl5.. But

Re: String interpolation

2004-07-20 Thread Alexey Trofimenko
On Tue, 20 Jul 2004 16:06:40 -0700, Larry Wall <[EMAIL PROTECTED]> wrote: Actually, I've been rethinking this whole mess since last week, and am seriously considering cranking up the Ruby-o-meter here just a tad. At the moment I'm inclined to say that the *only* interpolators in double quotes are:

Re: String interpolation

2004-07-20 Thread Damian Conway
Larry wrote: Actually, I've been rethinking this whole mess since last week, and am seriously considering cranking up the Ruby-o-meter here just a tad. At the moment I'm inclined to say that the *only* interpolators in double quotes are: \n, \t etc. $foo @foo[$i] %foo{$k} {EXPR}

Re: String interpolation

2004-07-20 Thread Uri Guttman
> "LW" == Larry Wall <[EMAIL PROTECTED]> writes: LW> Actually, I've been rethinking this whole mess since last week, and LW> am seriously considering cranking up the Ruby-o-meter here just a tad. LW> At the moment I'm inclined to say that the *only* interpolators in LW> double quotes

Re: String interpolation

2004-07-20 Thread Larry Wall
On Tue, Jul 20, 2004 at 06:28:11PM -0400, Aaron Sherman wrote: : > My preference is "$file\.ext". Clear, light and ascii. : : That's fine as far as it goes, but how do you say what, in Perl 5, I : would use this for: : : "${foo}n" : : I like the ${} syntax, but I'm a shell guy from my earl

Re: string interpolation

2002-01-25 Thread Simon Cozens
On Fri, Jan 25, 2002 at 05:07:48PM -0800, Dew-Jones, Malcolm MSER:EX wrote: > Lets add an .interpolate method. The parameter(s) are rules that control > the interpolation, and the returned value is the interpolated string using > those rules. > > $result = 'scalar $vars (only) will be inte