[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] OOPs not based on Structs.



On Fri, Jun 02, 2000 at 11:16:34AM +0000, John Carter wrote:
> In most languages, Pascal derivatives, C++, smalltalk etc. At the heart of
> an object is the basic non-atomic data type, a struct. In perl an object
> can be a blessed reference to any of its data types. Scalar, Hash, Array
> or code fragment.

Perl has more data types than that!

> Question. What curious perl Arcana can we dredge up along the line of...
> "You can do ... in Perl because Perl Objects are not structs."

You can bless a glob and use all of its hash, array, scalar,
filehandle, and sub members.  You can even tie the first four.  Eg,

$fun = new Fun;
print $$fun $fun->foo, $$fun->{foo}, $$fun->[0], $$$fun, $$fun->();

calls your object in 6 different ways.

Andrew

-- 
Where is the innovation?  Microsoft, mostly.
- Rob Pike, "Systems Software Research is Irrelevant"
  http://www.cs.bell-labs.com/cm/cs/who/rob/utah2000.ps

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe