Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Exists and Delete

2 views
Skip to first unread message

Rod Adams

unread,
Mar 15, 2005, 2:12:31 AM3/15/05
to Perl6 Language List
How am I supposed to define a signature that says "A scalar that refers
to a hash or array element, but do not evaluate or autovivify the element"?

Or are these two are now strictly methods without functional forms?

-- Rod Adams

Thomas Sandlaß

unread,
Mar 15, 2005, 12:57:02 PM3/15/05
to Rod Adams, Perl6 Language List
Rod Adams wrote:
> How am I supposed to define a signature that says "A scalar that refers
> to a hash or array element, but do not evaluate or autovivify the element"?

I'll make a guess: Ref of Int of Array.
This assumes Int has a polymorphic subtype that allows
pointing into arrays. But unfortunately you need two values
to describe the reference: the index and the array. So it should
be more like a pair: Ref of Pair[Int,Array].

my @array;
my Ref of Int of Array $iref = 17 of $array; # 17 => @array perhaps

$iref = "blahh";
say "@array[17]"; # prints blahh


> Or are these two are now strictly methods without functional forms?

Sorry I don't know what you are asking for. What is then a method with
functional form? Do you mean that the entries in an array are off-limits
to the outside and can be accessed only by the subscripting methods?

Regards,
--
TSa (Thomas Sandlaß)


Rod Adams

unread,
Mar 15, 2005, 1:44:06 PM3/15/05
to Perl6 Language List
Thomas Sandlaß wrote:

What I'm asking is if we are going to continue allowing:

delete %x<foo>;
if exists %x<foo> { ... }

or make it where you instead have to say

%x.delete('foo');
if %x.exists('foo') { ... }


-- Rod Adams

>
> Regards,


Juerd

unread,
Mar 15, 2005, 1:47:58 PM3/15/05
to Rod Adams, perl6-l...@perl.org
Rod Adams skribis 2005-03-15 12:44 (-0600):

> %x.delete('foo');
> if %x.exists('foo') { ... }

Would renaming exists to has or hasa be a good idea, if it does indeed
exist only in method form?


Juerd
--
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html
http://convolution.nl/gajigu_juerd_n.html

Larry Wall

unread,
Mar 15, 2005, 1:58:20 PM3/15/05
to Perl6 Language List
On Tue, Mar 15, 2005 at 12:44:06PM -0600, Rod Adams wrote:
: What I'm asking is if we are going to continue allowing:

:
: delete %x<foo>;
: if exists %x<foo> { ... }
:
: or make it where you instead have to say
:
: %x.delete('foo');
: if %x.exists('foo') { ... }

They can always just be macros that translate the unary form to the
method. If you define them as term:<delete> and term:<exists> they
won't show up unexpectedly when the parser is looking for method names.

Larry

Larry Wall

unread,
Mar 15, 2005, 2:20:54 PM3/15/05
to perl6-l...@perl.org
On Tue, Mar 15, 2005 at 07:47:58PM +0100, Juerd wrote:
: Rod Adams skribis 2005-03-15 12:44 (-0600):

: > %x.delete('foo');
: > if %x.exists('foo') { ... }
:
: Would renaming exists to has or hasa be a good idea, if it does indeed
: exist only in method form?

I'd think that would be asking if the array has an *attribute* of
that name. Perl 6 objects aren't hashes...

Larry

Juerd

unread,
Mar 15, 2005, 2:22:37 PM3/15/05
to Larry Wall, perl6-l...@perl.org
Larry Wall skribis 2005-03-15 11:20 (-0800):

That makes sense. I think %x ~~ 'foo' will be used more than
%x.exists('foo') anyway.

0 new messages