🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.eiffel
Article #1269

Eiffel suggestion

#1269
From: James W. Gish
Date: Wed, 21 Dec 1988 23:29
38 lines
1450 bytes
One of the things that drove me nuts about Simula 67 was the absence
of a concatenation operator. It did have a TEXT attribute called
CONCAT, but it was rather unwieldy to use if you had to do much string
processing at all.

Unfortunately, unless I missed something, Eiffel doesn't even have a
CONCAT feature for STRING.  It does have prepend and append, but they
change the string they are applied to.  It would be nice to also have
something like this as a feature of STRING:

cat (s: STRING): STRING is
		-- Concatenate a copy of s to current string and return it
	local
		newstring: STRING;
	do
		newstring.Create( current.length + s.length );
		newstring := Current.duplicate;
		newstring.append( s );
		Result := newstring.duplicate
	end; -- cat

Thus,
	x: STRING is "Foo";
	putstring( x.cat("f").cat("a").cat("h!") );
yields:
	"Foofah!"
without changing x.

Try to do that with append !

Of course, "a".cat( x ) is NOT valid.  Maybe this makes sense from some
point of view, but certainly not from one of convenient language features.

Cheers.
-- 
Jim Gish
GTE Laboratories, Inc., Waltham, MA
CSNET: jgish@gte.com    UUCP:  ..!harvard!bunny!jwg1
Technical Details
Message-ID: <6385@bunny.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!husc6!bunny!jwg1

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!husc6!bunny!jwg1
From: jwg1@bunny.UUCP (James W. Gish)
Newsgroups: comp.lang.eiffel
Subject: Eiffel suggestion
Message-ID: <6385@bunny.UUCP>
Date: 21 Dec 88 23:29:46 GMT
Organization: GTE Laboratories, Waltham, MA
Lines: 38