Newsgroups: comp.lang.c++,comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!uunet!in1.uu.net!mole-end!mat
From: mat@mole-end.matawan.nj.us
Subject: Re: Smalltalk @ Operator in C++
Message-ID: <1995Mar17.050351.20851@mole-end.matawan.nj.us>
Organization: :
References: <3k7rdd$drs@News1.mcs.com>
Date: Fri, 17 Mar 1995 05:03:51 GMT
Lines: 32
Xref: glinda.oz.cs.cmu.edu comp.lang.c++:118012 comp.lang.smalltalk:21839

In article <3k7rdd$drs@News1.mcs.com>, jim.fleming@bytes.com (Jim Fleming) writes:
> 
> How do I convert Smalltalk programs that heavily use the @ method
> selector to C++?
> 
> The @ method selector is used for class Integer to create objects
> of class Point, which have an x and y coordinate. For example,
> a := 150 @ 200. sends the Integer (with a value of 150) a message
> with a method selector of @, the other Integer argument (with value 200),
> is passed with the message to the receiver, 150. The @ method creates
> a new Point object and returns it and a reference is saved in "a".
> 
> How do I do this in C++?

This sounds too simple to be a real question.  What's wrong with this:

	Point p;
		.. .. .. ..
		  .. .. .. ..
		    .. .. .. ..


	p = Point( 100, 150 );

(Assuming, of course, that the Point class has a constructor that can be
called with those arguments.)  (I've heard this syntax called `value
builder' and I use that term myself, but it has no official sanction.)
-- 
 (This man's opinions are his own.)
 From mole-end				Mark Terribile
 mat@mole-end.matawan.nj.us, Somewhere in Matawan, NJ
	(Training and consulting in C, C++, UNIX, etc.)
