Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

(dws)Re: Optimizing variable passing (code, peer review)

by dws (Chancellor)
on May 11, 2001 at 10:29 UTC ( #79650=note: print w/ replies, xml ) Need Help??


in reply to Optimizing variable passing (code, peer review)

Have you considered making properties first-class Objects? This could lead to greatly simplified code. Consider

package EmmisiveColor; sub new { my $pkg = shift; return bless [ @_ ], $pkg; } sub as_string { my $self = shift; "emmisiveColor @$self" }
And so on for the other properties. Properties become easier to enumerate. You can do away with the switch entirely. Assuming you're doing so within the context of an object that holds properties, your snippet reduces to something like:
sub simple_properties { my $self = shift; my @propstrings = map { $_->as_string() } $self->properties(); return "appearance Appearance {\n" . " material Material {\n" . " ", join("\n ", @propstrings), "\n" . " }\n" . "}\n"; }


Comment on (dws)Re: Optimizing variable passing (code, peer review)
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2014-07-10 23:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (217 votes), past polls