Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion newbie question....

Newsgroups: perl.perl6.internals
Path: archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-09!supernews.com!newshosting.com!nx02.iad01.newshosting.com!border1.nntp.ash.giganews.com!border2.nntp.sjc.giganews.com!nntp.giganews.com!cyclone-sf.pbi.net!216.218.192.242!news.he.net!news-hog.berkeley.edu!ucberkeley!newsfeed.stanford.edu!nntp.perl.org
Return-Path: <br...@brentdax.com>
Mailing-List: contact perl6-internals-h...@perl.org; run by ezmlm
Delivered-To: mailing list perl6-intern...@perl.org
Delivered-To: perl6-intern...@perl.org
Message-ID: <405232B2.5020101@brentdax.com>
Date: Fri, 12 Mar 2004 13:59:14 -0800
User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207)
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: Matt Greenwood <Matt.Greenw...@twosigma.com>
CC: perl6-intern...@perl.org
Subject: Re: newbie question....
References: <DB30501EDA9FE34CB686A124032C127E01EA3C4F@mxgbl1.twosigma.com>
In-Reply-To: <DB30501EDA9FE34CB686A124032C127E01EA3C4F@mxgbl1.twosigma.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on x1.develooper.com
X-Spam-Status: No, hits=-4.9 required=8.0 tests=BAYES_00 autolearn=ham 
	version=2.63
Approved: n...@nntp.perl.org
From: br...@brentdax.com (Brent \"Dax\" Royal-Gordon)
Lines: 40

Matt Greenwood wrote:
 > Firstly, you have made an assumption that the addition here is
 > equivalent to OR and carry, which may be correct for certain
 > representations of integral datatypes, but certainly isn't for any
 > kind of floating point arithmetic that I know of.

True enough, but I think I got my point across--concatenation is a 
fundamentally different operation from addition.

 > Secondly, you missed the point that I was making. The current add
 > opcodes defined in parrot are the following:
 >
(various combinations of PMC, INT, and NUM)
 >
 > I was simply asking why there wasn't an
 >
 > add(out STR, in STR, in STR)
 >
 > which seems reasonable. This is not a question of operator
 > overloading, but rather semantics - that's all.

I suppose that depends on what you want it to do.  If you want it to 
convert $2 and $3 to integers, add them, convert the result to a string, 
and put it in $1, then the answer is "that's not a common enough 
operation to warrant adding the extra opcodes"--especially since the 
I/S/N registers aren't supposed to be used for anything but optimizations.

If you want it to concatenate $2 and $3 and insert the result into $1, 
and remove the "concat" opcode altogether...well, the answer stems from 
the existence of add(in PMC, in PMC, in PMC).  What should that 
do--integer addition, or string concatenation?  Remember, some of our 
languages don't overload add for strings.  We need a separate concat(in 
PMC, in PMC, in PMC), so we might as well have concat(out STR, in STR, 
in STR) too.

-- 
Brent "Dax" Royal-Gordon <br...@brentdax.com>
Perl and Parrot hacker

Oceania has always been at war with Eastasia.