Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
scalar subscripting
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  20 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Gautam Gopalakrishnan  
View profile  
 More options Jul 8 2004, 7:12 am
Newsgroups: perl.perl6.language
From: tha...@gmail.com (Gautam Gopalakrishnan)
Date: Thu, 8 Jul 2004 21:12:16 +1000
Local: Thurs, Jul 8 2004 7:12 am
Subject: scalar subscripting
Hello,

I've tried the archives and the 'Perl 6 essentials' book and I can't
find anything
about string subscripting. Since $a[0] cannot be mistaken for array subscripting
anymore, could this now be used to peep into scalars? Looks easier than using
substr or unpack. Hope I've not missed anything obvious.

Cheers
Gautam


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Juerd  
View profile  
 More options Jul 8 2004, 7:16 am
Newsgroups: perl.perl6.language
From: ju...@convolution.nl (Juerd)
Date: Thu, 8 Jul 2004 13:16:51 +0200
Local: Thurs, Jul 8 2004 7:16 am
Subject: Re: scalar subscripting
Gautam Gopalakrishnan skribis 2004-07-08 21:12 (+1000):

> about string subscripting. Since $a[0] cannot be mistaken for array subscripting
> anymore, could this now be used to peep into scalars? Looks easier than using

$a[0] is $a.[0]. That means that if there is a @$a, it still is array
subscripting.

Accessing strings as if they are arrays was discussed recently. Please
read the archives. (groups.google.com is my favourite interface)

Juerd


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Luke Palmer  
View profile  
 More options Jul 8 2004, 7:19 am
Newsgroups: perl.perl6.language
From: l...@luqui.org (Luke Palmer)
Date: Thu, 8 Jul 2004 05:19:17 -0600
Local: Thurs, Jul 8 2004 7:19 am
Subject: Re: scalar subscripting

Gautam Gopalakrishnan writes:
> Hello,

> I've tried the archives and the 'Perl 6 essentials' book and I can't
> find anything
> about string subscripting. Since $a[0] cannot be mistaken for array subscripting
> anymore, could this now be used to peep into scalars? Looks easier than using
> substr or unpack. Hope I've not missed anything obvious.

Well, no, it can't really.  $a[0] now means what Perl 5 called $a->[0]
(or @$a[0]).  So it's still an array subscript, it's just subscripting
$a, not @a.

But there's talk about using the various character type methods to
return lists of characters.  So if you want the first byte of your
string, you can say:

    $str.bytes[0];

And if you want the first codepoint:

    $str.codepoints[0];

Etc.

Luke


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Hans Ginzel  
View profile  
 More options Jul 8 2004, 2:53 pm
Newsgroups: perl.perl6.language
From: h...@matfyz.cz (Hans Ginzel)
Date: Thu, 8 Jul 2004 20:53:24 +0200
Local: Thurs, Jul 8 2004 2:53 pm
Subject: Re: scalar subscripting

On Thu, Jul 08, 2004 at 09:12:16PM +1000, Gautam Gopalakrishnan wrote:
> about string subscripting. Since $a[0] cannot be mistaken for array subscripting
> anymore, could this now be used to peep into scalars? Looks easier than using

   Are there plans in Perl 6 for string modifiers? As they are in bash
eg.:
        ${var%glob_or_regexp}
        ${var%%glob_or_regexp}
        ${var#glob_or_regexp}
        ${var##glob_or_regexp}
        ${var/pattern/string}
        ${var:[+-=]word}

    Best regards

                                        Hans Ginzel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Luke Palmer  
View profile  
 More options Jul 8 2004, 11:54 pm
Newsgroups: perl.perl6.language
From: l...@luqui.org (Luke Palmer)
Date: Thu, 8 Jul 2004 21:54:12 -0600
Local: Thurs, Jul 8 2004 11:54 pm
Subject: Re: scalar subscripting

Hans Ginzel writes:
> On Thu, Jul 08, 2004 at 09:12:16PM +1000, Gautam Gopalakrishnan wrote:
> > about string subscripting. Since $a[0] cannot be mistaken for array subscripting
> > anymore, could this now be used to peep into scalars? Looks easier than using

>    Are there plans in Perl 6 for string modifiers?

Not exactly.  But method calls can be interpolated into strings, so most
of this is pretty straightforward:

> As they are in bash eg.:
>    ${var%glob_or_regexp}
>    ${var%%glob_or_regexp}

        my $newfile = "$str.subst(rx|\.\w+$|, '')\.bin";

>    ${var#glob_or_regexp}
>    ${var##glob_or_regexp}

        say "Basename is $str.subst(rx|.*/|, '')"

>    ${var/pattern/string}

        say "$str.subst(rx|foo|, 'bar')"

>    ${var:[+-=]word}

        # ${var:-word}
        say "You chose $($value // 'no value')";

        # ${var:=word}
        say "You chose $($value //= 'no value')";

        # ${var:?word}
        say "You chose $($value // die 'please choose a value')"

Luke


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonathan Worthington  
View profile  
 More options Jul 9 2004, 12:02 pm
Newsgroups: perl.perl6.language
From: jonat...@jwcs.net (Jonathan Worthington)
Date: Fri, 9 Jul 2004 17:02:48 +0100
Local: Fri, Jul 9 2004 12:02 pm
Subject: Re: scalar subscripting

Would that not be:-

    say "Basename is $(str.subst(rx|.*/|, ''))"

I thought when you were interpolating method calls you had to put brackets
$(object.meth), so that you could still write things like:-

$fh = open "$id.txt";  # OK, maybe my open syntax isn't right

Or is it that you can do:-

say "$object.meth()";

But not:-

say "$object.meth";

And the later (...) distinguish that we are doing a method call?

Or am I completely wrong?  :-)

Thanks,

Jonathan


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry Wall  
View profile  
 More options Jul 9 2004, 2:25 pm
Newsgroups: perl.perl6.language
From: la...@wall.org (Larry Wall)
Date: Fri, 9 Jul 2004 11:25:01 -0700
Local: Fri, Jul 9 2004 2:25 pm
Subject: Re: scalar subscripting
On Fri, Jul 09, 2004 at 05:02:48PM +0100, Jonathan Worthington wrote:

: Would that not be:-
:
:     say "Basename is $(str.subst(rx|.*/|, ''))"
:
: I thought when you were interpolating method calls you had to put brackets
: $(object.meth), so that you could still write things like:-
:
: $fh = open "$id.txt";  # OK, maybe my open syntax isn't right
:
: Or is it that you can do:-
:
: say "$object.meth()";
:
: But not:-
:
: say "$object.meth";
:
: And the later (...) distinguish that we are doing a method call?
:
: Or am I completely wrong?  :-)

No, just currently wrong. :-)  I changed my mind about it in A12,
partly on the assumption that $object.attr would actually be more
common than $file.ext, but also because a bogus method call is likely
to be noticed sooner than bad output data, and because noticing
goofs sooner rather than later is often construed to be a good thing.
(Though this attitude can be taken to extremes--see static typing.)

Larry


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Piers Cawley  
View profile  
 More options Jul 12 2004, 7:20 am
Newsgroups: perl.perl6.language
From: pdcaw...@bofh.org.uk (Piers Cawley)
Date: Mon, 12 Jul 2004 12:20:01 +0100
Local: Mon, Jul 12 2004 7:20 am
Subject: Re: scalar subscripting

Luke Palmer <l...@luqui.org> writes:
> Gautam Gopalakrishnan writes:
>> Hello,

>> I've tried the archives and the 'Perl 6 essentials' book and I can't
>> find anything
>> about string subscripting. Since $a[0] cannot be mistaken for array subscripting
>> anymore, could this now be used to peep into scalars? Looks easier than using
>> substr or unpack. Hope I've not missed anything obvious.

> Well, no, it can't really.  $a[0] now means what Perl 5 called $a->[0]
> (or @$a[0]).  So it's still an array subscript, it's just subscripting
> $a, not @a.

So, it should be possible to define

  method postcircumfix:[] is rw { ... }

in the String class to do the right thing? Or even to define it in some
Sequence trait that both arrays and strings share? Of course, the
putative method would have to take into account the calling context's
Unicode behaviour, but I can't see why it shouldn't be possible.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Juerd  
View profile  
 More options Jul 12 2004, 7:47 am
Newsgroups: perl.perl6.language
From: ju...@convolution.nl (Juerd)
Date: Mon, 12 Jul 2004 13:47:06 +0200
Local: Mon, Jul 12 2004 7:47 am
Subject: Re: scalar subscripting
Piers Cawley skribis 2004-07-12 12:20 (+0100):

>   method postcircumfix:[] is rw { ... }

Compared to Ruby, this is very verbose.

    def [] (key)
        ...
    end

    # Okay, not entirely fair, as the Ruby version would also
    # need []= defined for the rw part.

Could methods like "[]" and "{}" *default* to "postcircumfix:"?
Array-/Hash-like access is very natural for many objects and I think
deserves simplified syntax.

    method [] ($index) { .item $index }

    method {} ($key) { .arg $key }

(And I'm assuming <<>> will be a method of Object that uses
self.postcircumfix:{}.)

Perhaps by making this popular, we can get rid of AUTOLOAD junkies ;)

Juerd


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simon Cozens  
View profile  
 More options Jul 12 2004, 7:58 am
Newsgroups: perl.perl6.language
From: si...@simon-cozens.org (Simon Cozens)
Date: 12 Jul 2004 12:58:40 +0100
Local: Mon, Jul 12 2004 7:58 am
Subject: Re: scalar subscripting

ju...@convolution.nl (Juerd) writes:
> Could methods like "[]" and "{}" *default* to "postcircumfix:"?

A more interesting question is "does it mean anything for them *not* to be
postcircumfix"?

After all, the only other use would be "$foo.[]($bar, $baz)", which is
practically identical. Unless you want to make [$foo] the default, and I
suspect that would be unwise.

--
Also note that i knew  _far_ more about the people that call address
mungers names like 'lusers', 'egoists' or try to make luser giraffes.
        -- Megahal (trained on asr), 1998-11-06


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Juerd  
View profile  
 More options Jul 12 2004, 8:07 am
Newsgroups: perl.perl6.language
From: ju...@convolution.nl (Juerd)
Date: Mon, 12 Jul 2004 14:07:58 +0200
Local: Mon, Jul 12 2004 8:07 am
Subject: Re: scalar subscripting
Simon Cozens skribis 2004-07-12 12:58 (+0100):

> ju...@convolution.nl (Juerd) writes:
> > Could methods like "[]" and "{}" *default* to "postcircumfix:"?
> A more interesting question is "does it mean anything for them *not* to be
> postcircumfix"?

Not as a method, I think.

> After all, the only other use would be "$foo.[]($bar, $baz)", which is
> practically identical.

Unless I am mistaken, $foo.[]($bar, $baz) is a syntax error and to call
interpunction-methods explicitly (verbosely), the full names need to be
used: $foo.postcircumfix:[]($bar), and all other methods need to have
^<letter>\w*$ names.

> Unless you want to make [$foo] the default, and I suspect that would
> be unwise.

Hm, circumfix operators as methods? Interesting idea, but what would
that do with [ $foo, $bar ], where $foo and $bar have a very different
circumfix:[] operator?

Juerd


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Austin Hastings  
View profile  
 More options Jul 12 2004, 10:08 am
Newsgroups: perl.perl6.language
From: austin_hasti...@yahoo.com (Austin Hastings)
Date: Mon, 12 Jul 2004 07:08:52 -0700 (PDT)
Local: Mon, Jul 12 2004 10:08 am
Subject: Re: scalar subscripting

--- Juerd <ju...@convolution.nl> wrote:
> Piers Cawley skribis 2004-07-12 12:20 (+0100):
> >   method postcircumfix:[] is rw { ... }

> Compared to Ruby, this is very verbose.

>     def [] (key)
>         ...
>     end

>     # Okay, not entirely fair, as the Ruby version would also
>     # need []= defined for the rw part.

> Could methods like "[]" and "{}" *default* to "postcircumfix:"?

Do we want Larry to spend even a picosecond thinking about how to
reduce the number of characters required to declare something like
this?

> Array-/Hash-like access is very natural for many objects and I think
> deserves simplified syntax.

>     method [] ($index) { .item $index }

>     method {} ($key) { .arg $key }

I thought operators were generally considered global multisubs, simply
because it makes life interesting when you're dereferencing $a[1, 2]
otherwise.

(Not that it matters, other than increasing the number of places that
MMD has to search for candidates.)

Regardless, I don't agree that the huffman coding of postcircumfix:[]
needs to be reduced to that of "[]". You could write a pcf:[] macro, if
you wanted to.

> (And I'm assuming <<>> will be a method of Object that uses
> self.postcircumfix:{}.)

It seems intuitive that redefining one access would redefine the
other(s), but I want the override mechanism to be the same. I think
requiring a method definition for one notation and a multisub for the
other notation would be a mistake. So long as they are both overridden
as methods or both as subs, it's cool.

=Austin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonadab The Unsightly One  
View profile  
 More options Jul 11 2004, 11:06 pm
Newsgroups: perl.perl6.language
From: jona...@bright.net (Jonadab The Unsightly One)
Date: Sun, 11 Jul 2004 23:06:30 -0400
Local: Sun, Jul 11 2004 11:06 pm
Subject: Re: scalar subscripting

Larry Wall <la...@wall.org> writes:
> No, just currently wrong. :-) I changed my mind about it in A12,
> partly on the assumption that $object.attr would actually be more
> common than $file.ext,

Speaking of which, what's the cleanest way to interpolate filenames
with a fixed extension now?  "${file}.ext" ?  "$file\.ext" ?

Also, I guess that if "$foo.bar" is taken as a method call, then
"$file.$ext" is going to be trouble also, is that right?  An error?
Or will it treat the value of $ext as the name of a method, or maybe
look for a method starting with $ ?

> but also because a bogus method call is likely to be noticed sooner
> than bad output data, and because noticing goofs sooner rather than
> later is often construed to be a good thing.  (Though this attitude
> can be taken to extremes--see static typing.)

Quite.  Perl6 is last I checked moving in the direction of giving a
more informative error message later, rather than a syntax error
sooner, which IMO is a good thing.  Not that this is a case of that,
but it demonstrates that noticing sooner isn't necessarily always the
best way to go.  (Static typing is certainly an annoying limitation,
and I'm sure there are other examples.)

However, while it's a shame not to be able to interpolate "$file.ext",
I can certainly see the argument for "$object.method" being a common
case, one that I imagine I'll use quite often.

Of course, this leaves open the question of whether there are any
fairly common filename extensions that happen to be spelled the same
as a method on Perl6's string class, that might ought to have a
warning generated...   Are there any three-letter methods on the
string class?  (Maybe there shouldn't be, in the core language...)

--
$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}}
split//,"ten.thgirb\@badanoj$/ --";$\=$ ;-> ();print$/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Austin Hastings  
View profile  
 More options Jul 14 2004, 11:38 am
Newsgroups: perl.perl6.language
From: austin_hasti...@yahoo.com (Austin Hastings)
Date: Wed, 14 Jul 2004 08:38:31 -0700 (PDT)
Local: Wed, Jul 14 2004 11:38 am
Subject: Re: scalar subscripting
--- Jonadab the Unsightly One <jona...@bright.net> wrote:

> Of course, this leaves open the question of whether there are any
> fairly common filename extensions that happen to be spelled the same
> as a method on Perl6's string class, that might ought to have a
> warning generated...   Are there any three-letter methods on the
> string class?  (Maybe there shouldn't be, in the core language...)

Well, there was talk about the shortest-possible-name for, among
others, the codepoints and language-dependent-entities of strings.

We pretty well know that .c is a risk, and if language-dependent gets
spelled "per language", .pl might also be one. :-(

=Austin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry Wall  
View profile  
 More options Jul 14 2004, 1:23 pm
Newsgroups: perl.perl6.language
From: la...@wall.org (Larry Wall)
Date: Wed, 14 Jul 2004 10:23:18 -0700
Local: Wed, Jul 14 2004 1:23 pm
Subject: Re: scalar subscripting
On Sun, Jul 11, 2004 at 11:06:30PM -0400, Jonadab the Unsightly One wrote:
: Larry Wall <la...@wall.org> writes:
:
: > No, just currently wrong. :-) I changed my mind about it in A12,
: > partly on the assumption that $object.attr would actually be more
: > common than $file.ext,
:
: Speaking of which, what's the cleanest way to interpolate filenames
: with a fixed extension now?  "${file}.ext" ?  "$file\.ext" ?

Cleanliness is a relative concept, but I'd tend to go with the
backslash in this case.

Another alternative is "$( $file ).ext".  I'd tend to use that before
"${file}.ext" these days.  Perhaps that's irrational--but it was hard
to get the special-case "${name}" form to work right in the Perl 5
lexer, and that bugs me.  If we're going to get rid of the autoquoting
of $hash{shift}, we likely ought to undo the autoquoting of ${shift}
as well, even if that gives heartburn to a certain number of shell
programmers.

: Also, I guess that if "$foo.bar" is taken as a method call, then
: "$file.$ext" is going to be trouble also, is that right?  An error?
: Or will it treat the value of $ext as the name of a method, or maybe
: look for a method starting with $ ?

It will use the value of $ext as the name of the method.  Alternately,
we could simply disallow indirect method names inside interpolations.
They're very rare, and you could always say $( $file.$ext ) in that case.

: > but also because a bogus method call is likely to be noticed sooner
: > than bad output data, and because noticing goofs sooner rather than
: > later is often construed to be a good thing.  (Though this attitude
: > can be taken to extremes--see static typing.)
:
: Quite.  Perl6 is last I checked moving in the direction of giving a
: more informative error message later, rather than a syntax error
: sooner, which IMO is a good thing.  Not that this is a case of that,
: but it demonstrates that noticing sooner isn't necessarily always the
: best way to go.  (Static typing is certainly an annoying limitation,
: and I'm sure there are other examples.)

One error message that would be of great benefit to novices is if we
could guess where the missing brace is based on indentation.  (But not
*assuming* the missing brace, of course--this isn't Python...  :-)

: However, while it's a shame not to be able to interpolate "$file.ext",
: I can certainly see the argument for "$object.method" being a common
: case, one that I imagine I'll use quite often.

It's also a philosophical issue of making trying to make $object.method
look and behave exactly like a variable.  This carries through to several
other design decisions, such as allowing "temp $object.method".

: Of course, this leaves open the question of whether there are any
: fairly common filename extensions that happen to be spelled the same
: as a method on Perl6's string class, that might ought to have a
: warning generated...   Are there any three-letter methods on the
: string class?  (Maybe there shouldn't be, in the core language...)

Yes.  We might also need to be careful about doing failover from
$foo.bar(1) to bar($foo,1).  Otherwise any multimethod that allows a
string as the first argument could also be confused with an extension.

I suppose another approach is simply to declare that dot is always a
metacharacter in double quotes, and you have to use \. for a literal
dot, just as in regexen.  That approach would let us interpolate
things like .foo without a variable on the left.  That could cause
a great deal of cultural confusion in the short term, however.

On the other hand, that raises the issue of what this should match:

    /$foo.bar/

and if we let people interpolate .bar into strings, then what will they
expect this to do:

    /.bar/

Ouch.  I'm thinking we allow $foo.bar in both strings and regexen, but
not .bar in either case.  Gotta use $_.bar inside strings and regexen.
(Or $(.bar) would work too.)  Possibly we even complain about /.bar/
and force them to write /. bar/.

Likewise, /$foo.$bar/ should probably also be forcibly disambiguated
to either /$( $foo.$bar )/ or /$foo . $bar/.

Larry


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry Wall  
View profile  
 More options Jul 14 2004, 1:34 pm
Newsgroups: perl.perl6.language
From: la...@wall.org (Larry Wall)
Date: Wed, 14 Jul 2004 10:34:37 -0700
Local: Wed, Jul 14 2004 1:34 pm
Subject: Re: scalar subscripting
On Wed, Jul 14, 2004 at 10:23:18AM -0700, Larry Wall wrote:

: Another alternative is "$( $file ).ext".  I'd tend to use that before
: "${file}.ext" these days.  Perhaps that's irrational--but it was hard
: to get the special-case "${name}" form to work right in the Perl 5
: lexer, and that bugs me.  If we're going to get rid of the autoquoting
: of $hash{shift}, we likely ought to undo the autoquoting of ${shift}
: as well, even if that gives heartburn to a certain number of shell
: programmers.

And if we do that, I guess that means that "$«file».ext" could
be made to work as a replacement, which seems conceptually clean if
you don't think about it too hard.

Larry


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dan Hursh  
View profile  
 More options Jul 14 2004, 2:11 pm
Newsgroups: perl.perl6.language
From: hu...@infonet.isl.net (Dan Hursh)
Date: Wed, 14 Jul 2004 13:11:18 -0500
Local: Wed, Jul 14 2004 2:11 pm
Subject: Re: scalar subscripting

Larry Wall wrote:
> On Wed, Jul 14, 2004 at 10:23:18AM -0700, Larry Wall wrote:
> : Another alternative is "$( $file ).ext".  I'd tend to use that before
> : "${file}.ext" these days.  Perhaps that's irrational--but it was hard
> : to get the special-case "${name}" form to work right in the Perl 5
> : lexer, and that bugs me.  If we're going to get rid of the autoquoting
> : of $hash{shift}, we likely ought to undo the autoquoting of ${shift}
> : as well, even if that gives heartburn to a certain number of shell
> : programmers.

> And if we do that, I guess that means that "$«file».ext" could
> be made to work as a replacement, which seems conceptually clean if
> you don't think about it too hard.

Maybe I'm missing something here, but this looks just plain cruel.  Is
it easier to parse ...um... that?  It's that same debate that's been
here before, but a lot of us can't type it yet.  I probably could, but I
don't know the incantation for mozilla on windows.  If I did, it bet it
wouldn't be the same as as the raindance for notepad.  If it is the
same, then it probably isn't the same as the incantation in vi or emacs
on linux or aix.

I use "...${var}..." a lot, and unfortunately, I have to use a number of
different programs and oses.  Unfortunately, typing '«' & '»' (thank you
cut&paste) is not as portable on the keyboard as say '{' & '}' (or '&'
for that matter).

Is ${var} really that rare in real world perl?  Are we going to try to
have ascii equivalents like '<<' & '>>' in quoted strings?  (Please no.)
  Do I need to put a unicode keyboard next to the APL keyboard on my
wishlist?

Dan


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Mastros  
View profile  
 More options Jul 15 2004, 2:08 am
Newsgroups: perl.perl6.language
From: ja...@mastros.biz (James Mastros)
Date: Thu, 15 Jul 2004 08:08:13 +0200
Local: Thurs, Jul 15 2004 2:08 am
Subject: Re: scalar subscripting

Larry Wall wrote:
> I suppose another approach is simply to declare that dot is always a
> metacharacter in double quotes, and you have to use \. for a literal
> dot, just as in regexen.  That approach would let us interpolate
> things like .foo without a variable on the left.  That could cause
> a great deal of cultural confusion in the short term, however.

[...]
> Ouch.  I'm thinking we allow $foo.bar in both strings and regexen, but
> not .bar in either case.  Gotta use $_.bar inside strings and regexen.
> (Or $(.bar) would work too.)  Possibly we even complain about /.bar/
> and force them to write /. bar/.

Please, think of C<say "This is a sentence.  This is another
sentence.";>.  Dots with whitespace or end-of-string after them should
just be literal dots in qq strings.  Dots should always be literals in
q() strings, of course.  And dots are /already/ metacharacters in
regex^Wrules; forcing a space after the dot isn't giving the power of
formatting to the user; it's forcing formatting upon them that they
don't want.  (I don't remember if there's an adverb to treat spaces as
literals, but if not, there should be.)

I think method calls in strings should be "Foo's bar is $($foo.bar).",
plain and simple.  Dot is too useful here already.  @{[...]} needed to
be replaced with something easier to type, and with clearer (and
cleaner) semantics.  We did that; $(...) is far better.  Not requiring a
set off for method calls is Huffman coding the wrong direction, unless
you can find one that won't disturb useful things that you'd want in
double-quotes -- which includes patterns common in any natural language,
which includes even the literal versions of << / >> (which I can't type
easily at the moment).

        -=- James Mastros


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonadab The Unsightly One  
View profile  
 More options Jul 17 2004, 10:59 am
Newsgroups: perl.perl6.language
From: jona...@bright.net (Jonadab The Unsightly One)
Date: Sat, 17 Jul 2004 10:59:27 -0400
Local: Sat, Jul 17 2004 10:59 am
Subject: Re: scalar subscripting

Larry Wall <la...@wall.org> writes:
> And if we do that, I guess that means that "$«file».ext" could be
> made to work as a replacement, which seems conceptually clean if you
> don't think about it too hard.

Now that you put it that way, $( $file ).ext doesn't seem so bad, the
visually-distracting double $ notwithstanding.

--
$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}}
split//,"ten.thgirb\@badanoj$/ --";$\=$ ;-> ();print$/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Hans Ginzel  
View profile  
 More options Jul 19 2004, 12:20 pm
Newsgroups: perl.perl6.language
From: h...@matfyz.cz (Hans Ginzel)
Date: Mon, 19 Jul 2004 18:20:18 +0200
Local: Mon, Jul 19 2004 12:20 pm
Subject: Re: scalar subscripting

        Hello,

   I wish to be consistent with shall, so `.' is literal dot in double
strings. I prefer "$file.ext" or "${file}.ext".

   For method calls ``$()'' could be used: "$($foo.bar)".

   Perhaps, what does "${foo.bar}" mean?

        Best regards
                                        Hans


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »