Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^4: Getting for() to accept a tied array in one statement

by hdb (Monsignor)
on Apr 16, 2019 at 13:55 UTC ( #1232654=note: print w/replies, xml ) Need Help??


in reply to Re^3: Getting for() to accept a tied array in one statement
in thread Getting for() to accept a tied array in one statement

But isn't the whole point of tie that one can use the tied array as if it were a normal array and all the magic happens without ever calling the classes' methods explicitly?

Replies are listed 'Best First'.
Re^5: Getting for() to accept a tied array in one statement
by Veltro (Hermit) on Apr 16, 2019 at 14:09 UTC

    Yes, my point is that you simply can't assume an object can be de-referenced to an array. The tie mechanism useful for creating algorithms that can handle objects without implying knowledge about their implementation. Otherwise this would defeat the whole purpose using tie. So it is still a good question, any other solutions appreciated.

      But that statement refers to the reference returned by tie which is not an array reference. The tied array works like a normal array.

        I don't understand, what you call 'not an array reference' is what I call 'object', so don't we mean the same thing?

        In:

        use ar ; my @ar ; my $art = tie @ar, "ar" ; @ar = (1, 2) ;

        My point is, I cannot know what $art is, so to me this is a big no no:

        my @ar-deref = @{$art};

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1232654]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2021-04-11 22:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?