develooper Front page | perl.perl6.internals | Postings from October 2001

Opcode complaints

Thread Next
From:
Brent Dax
Date:
October 27, 2001 22:48
Subject:
Opcode complaints
Message ID:
FJELLKOPEAGHOOODKEDPMEMMCIAA.brentdax@cpan.org
Okay, now that I've had some time working with Parrot assembler, I've
developed a list of complaints.  ;^)

1. No if(s|sc, i|ic)
We're treating strings as second-class citizens here.  Why shouldn't you
be able to do an 'if' on a string?  You could interpret it as the
string's length, or the string's length && string ne "0".

2. No unless
'unless' is often more useful than 'if'.  Observe:

	# if(I0) {some stuff} else {other stuff}
	if I0, BeginIF
	branch ElseIF
	BeginIF: some stuff
	branch EndIF
	ElseIF: other stuff
	EndIF:

vs.

	unless I0, ElseIF
	some stuff
	branch EndIF
	ElseIF: other stuff
	EndIF:

In the first case, the if block uses two branches, and in the second it
only uses one.  Maybe I'm just being nitpicky, but I find the second one
a lot cleaner.

3. eq and friends: branching
The greatest oddity I've found so far is the eq operator and its pals.
While I'm sure these'll be great for something like 'if($foo eq $bar)',
they're less than optimal for anything more complicated: 'if($foo eq
$bar && $foo eq $baz)', or even the simple '$foobar=$foo eq $bar'.  The
best way I've found so far to use eq and friends in a generic way is:

	#I0=I1 eq I2
	eq I1, I2, YES
	set I0, 0
	branch END
	YES: set I0, 1
	END:

That's pretty suboptimal, considering that it could be:
	eq I0, I1, I2

and even the if case would just be:

	#if(I1 eq I2)
	#I0 is the temp register
	eq I0, I1, I2
	if I0, ...

That's a lot cleaner, isn't it?

4. eq and friends: string variants
One thing that seems to be missing is string and numeric variants on the
comparison ops.  While this isn't a problem now, it may be once we get
PMCs.

I can probably write a patch to fix all this, but first we have to
decide if it needs fixing.  Some of these are kind of nitpicky, but
they're still things I find annoying.  Thoughts?

--Brent Dax
brentdax@cpan.org
Configure pumpking for Perl 6

When I take action, I’m not going to fire a $2 million missile at a $10
empty tent and hit a camel in the butt.
    --Dubya


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About