Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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"; }

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 rifling through the Monastery: (6)
As of 2016-09-25 19:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (472 votes). Check out past polls.