How can I use the string variable expansion for OO "$self->attribute"

  • Thread starter Ilias Lazaridis
  • Start date
U

Uri Guttman

IL> please!

IL> I just provide links, thus future readers can follow the thread
IL> immediately.

but links to other sites which just have perl docs. tell them to use
THEIR OWN perldocs that come with perl.

IL> but I cannot see how I can overload / tie the default array to
IL> [...] - (tie etc.)

IL> (duplicate message due to problems with google-groups)

IL> relevant comments here:
IL> http://groups.google.com/group/comp.lang.perl.misc/msg/0a355d7ecbd4747c

huh?? you haven't made any relevant comments yet.

uri
 
I

Ilias Lazaridis

IL> I cannot findout how to implement this below with perltie:

IL> perl [http://search.cpan.org/~nwclark/perl-5.8.8/lib/overload.pm
IL> overload] provides functionality for operators:

as i said before tie is for variables. [...]

IL> is there a similar module to overload the classes of build in types
IL> (like array), something like:

IL> {{{
IL> #!perl
IL> use typeoverload
IL> '@' => 'My::Array',
IL> '%' => 'My::Hash';
IL> # etc
IL> ...
IL> }}}

you can't do this for all variables at one time.
[...]

ok, I summarize that there is no direct construct available to achieve
the above.

thank you for your reply.

..
 
I

Ilias Lazaridis

[...]
is there a similar module to overload the classes of build in types
(like array), something like:
{{{
#!perl
use typeoverload
'@' => 'My::Array',
'%' => 'My::Hash';
# etc
...
}}}

You don't want to do that, and thankfully Perl won't let you. Do you
seriously want to make every low-level Perl array access attempt go
through My::Array?

If it were me, I'd just use the traditional syntax for interpolating
complex expressions within strings @{[ $self->val($attrib) ]}. You seem
to think that's ugly. To each his own.

There is little chance that the path you are on right now will lead you
to success, and there's almost no chance that you'll find a more
efficient and simple solution than Tie::Sub.

Oh well. Good luck.
 
I

Ilias Lazaridis

....

IL> I just provide links, thus future readers can follow the thread
IL> immediately.

but links to other sites which just have perl docs. tell them to use
THEIR OWN perldocs that come with perl.

They can decide themselves where they read the docs.
IL> but I cannot see how I can overload / tie the default array to
IL> [...] - (tie etc.)

IL> (duplicate message due to problems with google-groups)

IL> relevant comments here:
IL>http://groups.google.com/group/comp.lang.perl.misc/msg/0a355d7ecbd4747c

huh?? you haven't made any relevant comments yet.

as said, google has some problems (delays, some message seem to not
appear).

..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top