Front page | perl.perl5.porters |
Postings from November 2003
Re: Not enough arguments
Thread Previous
|
Thread Next
From:
Michael G Schwern
Date:
November 1, 2003 21:11
Subject:
Re: Not enough arguments
Message ID:
20031102051047.GD3659@localhost.comcast.net
On Fri, Oct 31, 2003 at 07:27:24PM +0300, Alexey Tourbin wrote:
> Thanks for explanation. Here is two patches I recently made that fix
> syntax check (JFYI).
Might I suggest that you use &Foo(@_) instead of relying on the
umm... "feature" of @_ being passed along from one subroutine to another
when &foo syntax is used? Otherwise somebody's going to come along and
go "geez, why is he using that stupid &foo style? I'll just change it to
foo()..."
Or goto &foo. Or *bar = \&foo which is simple and most efficient.
Especially dangerous is that &glVertex3d call. Plus the fairly poor
variable names $arg1, $arg2 and $arg3. I presume they're $x, $y and $z or
$red, $green and $blue? I would recommend that rather than doing the
splits into scalars all over the code like you have that you create
a simple wrapper function which does that for you.
> --- XML-Sablotron-0.98/Sablotron.pm- 2003-04-07 10:19:48 +0000
> +++ XML-Sablotron-0.98/Sablotron.pm 2003-10-17 17:05:38 +0000
> @@ -80,11 +80,11 @@
> ############################################################
>
> sub SablotProcessStrings {
> - ProcessStrings(@_);
> + &ProcessStrings;
> }
>
> sub SablotProcess {
> - Process(@_);
> + &Process;
> }
>
> #sub SablotRegMessageHandler {
>
>
> --- PDL-2.4.0/Graphics/TriD/TriD/Lines.pm- 1999-12-09 11:15:17 +0000
> +++ PDL-2.4.0/Graphics/TriD/TriD/Lines.pm 2003-10-30 19:04:02 +0000
> @@ -41,7 +41,7 @@ sub togl {
> }
> my $color = pop @_;
> glColor3f($color,0,1-$color);
> - glVertex3d(@_);
> + &glVertex3d;
> # print "VERTEX: ",(join ",",@_),"\n";
> }) ;
> glEnd();
> --- PDL-2.4.0/Graphics/TriD/TriD/MathGraph.pm- 2000-06-09 12:34:08 +0000
> +++ PDL-2.4.0/Graphics/TriD/TriD/MathGraph.pm 2003-10-30 19:24:49 +0000
> @@ -37,7 +37,8 @@ sub gdraw {
> my($this,$points) = @_;
> glDisable(&GL_LIGHTING);
> # print "Color: $this->{Color} @{$this->{Color}}\n";
> - glColor3d(@{$this->{Options}{Color}});
> + my ($arg1,$arg2,$arg3) = @{$this->{Options}{Color}};
> + glColor3d($arg1,$arg2,$arg3);
> PDL::Graphics::OpenGLQ::gl_arrows($points,$this->{Options}{From},
> $this->{Options}{To},$this->{ArrowLen},$this->{ArrowWidth});
> glEnable(&GL_LIGHTING);
> --- PDL-2.4.0/Graphics/TriD//TriD/Mesh.pm- 2000-10-01 07:23:50 +0000
> +++ PDL-2.4.0/Graphics/TriD//TriD/Mesh.pm 2003-10-31 11:36:46 +0000
> @@ -117,16 +117,19 @@ sub togl {
> print "ONESTRIP\n", (join '',
> $this->{Normals}->slice(":,($x),($y),($x),($y)")
> ),"\n";
> - glNormal3d(
> - $this->{Normals}->slice(":,($x),($y),($x),($y)")
> - ->list());
> + my ($arg1,$arg2,$arg3) = $this->{Normals}->slice(":,($x),($y),($x),($y)")->list();
> + glNormal3d($arg1,$arg2,$arg3);
> # print "VERTEX0: ",(join ',',
> # $this->{Vertices}->slice(":,($x),($y)")->list()),
> # "\n";
> - glVertex3d($this->{Vertices}->slice(":,($x),($y)")->list());
> - glVertex3d($this->{Vertices}->slice(":,($x1),($y)")->list());
> - glVertex3d($this->{Vertices}->slice(":,($x),($y1)")->list());
> - glVertex3d($this->{Vertices}->slice(":,($x1),($y1)")->list());
> + ($arg1,$arg2,$arg3) = $this->{Vertices}->slice(":,($x),($y)")->list();
> + glVertex3d($arg1,$arg2,$arg3);
> + ($arg1,$arg2,$arg3) = $this->{Vertices}->slice(":,($x1),($y)")->list();
> + glVertex3d($arg1,$arg2,$arg3);
> + ($arg1,$arg2,$arg3) = $this->{Vertices}->slice(":,($x),($y1)")->list();
> + glVertex3d($arg1,$arg2,$arg3);
> + ($arg1,$arg2,$arg3) = $this->{Vertices}->slice(":,($x1),($y1)")->list();
> + glVertex3d($arg1,$arg2,$arg3);
> glEnd();
> # Show normal
> # glBegin(&GL_LINES);
--
Michael G Schwern schwern@pobox.com http://www.pobox.com/~schwern/
But I wore the juice!
Thread Previous
|
Thread Next