Re: URL's (was Re: Perl 5 LWP Design)

Jack Shirazi - BIU (js@bison.lif.icnet.uk)
Tue, 7 Mar 95 11:00:31 GMT


> > > Are you sure that URL should be an object?  That seems like an awful
> > > lot of overhead for a piece of data,
> > 
> > I don't quite know what the overhead is, and given that Larry hasn't
> > given much thought to optimisation in Perl 5 I'm not sure it's
> > something we should worry about.
> > 
> Objects are very cheap. Feel free to use them widely.

Indeed, let me add my two pence. There is actually the opposite of an overhead
(underhead?) in using the object, since instead of copying strings
every time you pass the URL, you are copying a reference, which
is generally quicker (exactly as in C it's quicker to pass a pointer to
the string than the string itself, unless the string is smaller
than a pointer).

> > > and the behaviour is not really object-like.  Wouldn't a data
> > > structure be more appropriate?  I know it would be in C++, but am
> > > not sure about perl5.
> > 
> > In Perl 5 there appears to be little difference between the two,
> > an object is just a data structure blessed into a class.
> > 
> Indeed.

Objects in all languages are just data structures which can respond
to messages. Perl is no different. In C++ it would be perfectly reasonable
to have the URL as an object rather than a plain struct - in fact for someone
such as myself raised on Smalltalk, this is the 'correct' way to do it
(the only way in Smalltalk :-) - its only the C-hangups of C++ programmers
that get them stuck on structs rather than classes.

:-)

------      Jack               js@biu.icnet.uk