RE: stringification of objects, subroutine refs

2002-05-11 Thread Brent Dax

[EMAIL PROTECTED]:
# I was wondering how perl6 would stringify (as in Data::Dumper):

As Dan said, that's serialization.  I don't know if Perl will support
that built-in.  But if it does...

#   1) objects with 'my' and 'our' variables

Those would have to be dumped from the pads or stashes.  I don't think
there's any way around that.

#   2) $.property

Using their accessors?

#   2) subroutines (and coderefs)

See my comment below.

#   3) properties (both is/has)

'is' properties are part of the code, so I don't think they need
serialization.  'has' (or whatever it'll be called) properties can be
applied easily--remember, a 'has' returns its left operand.

# Right now, the fact that subroutines come out as 'sub { 
# DUMMY }' is a minor pain to work around, having all of 
# these as holes would be too much IMO.

That's fixed in 5.8--it uses B::Deparse to make a rough version of the
sub.  Just hope it isn't a closure.

--Brent Dax [EMAIL PROTECTED]
@roles=map {Parrot $_} qw(embedding regexen Configure)

blink:  Text blinks (alternates between visible and invisible).
Conforming user agents are not required to support this value.
--The W3C CSS-2 Specification




Attribute vs. Property

2002-05-11 Thread David Wheeler

I just want to verify that I properly understand the use of these two terms
in Perl 6.

  * An attribute is a data member of a class.
  * A property is a piece of metadata on a...uh...thing -- e.g., on an
attribute, on a class, or on a method.

Do I have it right?

For some reason, I've always referred to class data members as properties,
and thought of metadata on such things as attributes -- the reverse of the
above. This despite the use of attribute in the above usage in Damian's
book. So do I just need to turn myself around (at least when talking about
Perl), or is there a chance that the language designers would decide that
the way I use the terms is ever-so-much-better? ;-)

Regards,

David

-- 
David Wheeler AIM: dwTheory
[EMAIL PROTECTED] ICQ: 15726394
http://david.wheeler.net/  Yahoo!: dew7e
   Jabber: [EMAIL PROTECTED]





Selective exporting of properties/methods

2002-05-11 Thread Chris Dutton

While thinking Eiffel-ish thoughts the other day, I began to wonder if 
Perl6's classes could go beyond the simple private/public/protected 
scheme by optionally allowing for a property or method to only be 
accessed by a certain set of classes.  For instance(as I understand 
Perl6 syntax):

class Foo {
method hello is public {
return hello;
}
method world is public_to(Bar) {
# is only public to objects of class Bar
return world;
}
}

class Bar {
method say_hello {
# this works fine
print Foo.new.hello, \n;
}
method say_world {
# as does this
print Foo.new.world, \n;
}
}

class Baz {
method say_world {
# generates a run-time exception for trying to call a private method.
print Foo.new.world, \n;
}
}




Re: Accessor methods ?

2002-05-11 Thread Paul Johnson

On Fri, May 10, 2002 at 11:27:53PM -0400, Chris Dutton wrote:
 
 On Friday, May 10, 2002, at 09:54  PM, Damian Conway wrote:
 
 That's getting a little ugly, so maybe we'd lift the syntax from 
 Eiffel instead:
 
  method set_baz($newbaz is like($.baz)) { $.baz = $newbaz }
 
 This is exactly what went through my mind about a half second after I 
 posted the message.
 
 $newbaz is like($.baz), I would think, would have to raise a run-time 
 exception if $newbaz isn't like $.baz.

I've always found the word like to be very wishy-washy in a computer
langauge.  In what way is newbaz like baz?  And just how alike are they?

There must be a better way to describe this.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net



Re: Attribute vs. Property

2002-05-11 Thread Damian Conway

David Wheeler wrote:

 I just want to verify that I properly understand the use of these two terms
 in Perl 6.

and in the wider OO community, BTW.


   * An attribute is a data member of a class.

Yes.


   * A property is a piece of metadata on a...uh...thing -- e.g., on an
 attribute, on a class, or on a method.

or on a subroutine, closure, or value.


 Do I have it right?

Yes.


 So do I just need to turn myself around (at least when talking about
 Perl), or is there a chance that the language designers would decide that
 the way I use the terms is ever-so-much-better? ;-)

Well, I suppose there's always a *chance* that we'd both completely reverse
our careful thinking on this issue and ignore the common usage of attribute
in the OO literature. But I do think it would be easier all round if you just 
went with our chosen terminology for Perl 6. ;-)

Damian



Re: Attribute vs. Property

2002-05-11 Thread David Wheeler

On 5/11/02 2:48 PM, Damian Conway [EMAIL PROTECTED] claimed:

 Well, I suppose there's always a *chance* that we'd both completely reverse
 our careful thinking on this issue and ignore the common usage of attribute
 in the OO literature. But I do think it would be easier all round if you just
 went with our chosen terminology for Perl 6. ;-)

Damn. I was afraid you were going to say that! :-)

Thanks for the reply.

Regards,

David

-- 
David Wheeler AIM: dwTheory
[EMAIL PROTECTED] ICQ: 15726394
http://david.wheeler.net/  Yahoo!: dew7e
   Jabber: [EMAIL PROTECTED]





Re: Accessor methods ?

2002-05-11 Thread David Wheeler

On 5/11/02 2:43 PM, Damian Conway [EMAIL PROTECTED] claimed:

 method set_baz($newbaz is compatible($.baz)) { $.baz = $newbaz }
 method set_baz($newbaz is typeof($.baz)) { $.baz = $newbaz }

I like the latter best -- and it beats the hell out of instanceof ;-)

Regards,

David

-- 
David Wheeler AIM: dwTheory
[EMAIL PROTECTED] ICQ: 15726394
http://david.wheeler.net/  Yahoo!: dew7e
   Jabber: [EMAIL PROTECTED]





Re: Accessor methods ?

2002-05-11 Thread Pixel

David Wheeler [EMAIL PROTECTED] writes:

 On 5/11/02 2:43 PM, Damian Conway [EMAIL PROTECTED] claimed:
 
  method set_baz($newbaz is compatible($.baz)) { $.baz = $newbaz }
  method set_baz($newbaz is typeof($.baz)) { $.baz = $newbaz }
 
 I like the latter best -- and it beats the hell out of instanceof ;-)

talking about instanceof, here are the various syntaxes:

* testing class membership

  x isax Perl x
  x is_a? kind_of? x Ruby x
  x dynamic_cast   x C++  x
  x instanceof x Java x
  x isinstance x Python   x
  x in x Ada  x
  x is x C#   x
  x is_a   x PHP  x
  x entry_type x Pliant   x
  x ISTYPE x Modula-3 x
  x object##  classname## x Beta x
  x var ?= val (20)x Eiffel   x

* get the class corresponding to an object/instance

  x type  x Ruby   x
  x __class__ x Python x
  x getClass  x Java   x
  x typeidx C++x

if you know some more, tell me :)

http://merd.net/pixel/language-study/syntax-across-languages.html