development

I said it was harder

December 27, 2004 16:28:48.892

Look how much work Sriram Krishnan goes through trying to do something like this:

someCollection select: [:each | each passesSomeTest]

Hmm - that type checking is really coming in handy, hmm? Related comments from Patrick Logan here

Comments

Shock horror it's programmer error!

[Isaac Gouy] December 27, 2004 17:27:12.007

"Update: I made a major goof-up here."

"In C# 2.0, with anonymous delegates, everything I've written is unnecessary.

Map

[Isaac Gouy] December 27, 2004 17:38:11.341

something like this:

No, something like this:

someCollection collect: [:each | each applyFunction]

Not much harder

[Alex] December 27, 2004 18:54:55.274

Even in current C# it is only:

	ArrayList myList = new ArrayList;

	foreach (IMyStuff item in listArg) {
		myList.Add(funDelegate(item));
	}

	return myList;

I said it was harder

[ Michael Lucas-Smith] December 28, 2004 0:15:17.706

Comment by Michael Lucas-Smith

That's still too much typing. To compare:

myList := OrderedCollection new.
listArg do: [:item | myList add: item funDelegate].
^myList
Versus:
listArg collect: [:item | item funDelegate]

[Sriram] December 28, 2004 0:22:46.220

I agree that in C#, it sucks...now. C# 2.0 makes it easier as do C-Omega (the research language). This is a limitation of the language rather than the .NET runtime. But the way C# makes you jump through hoops to do something as simple as Map is just ridiculous

Uh huh..

[Michael Walter] December 28, 2004 8:05:05.400

In Haskell, it's:

map applyFunction someCollection

Hmm, that type checking is really coming in handy! ;-)

I said it was harder?

[Alex] December 28, 2004 12:03:45.159

Michael,

No fair! All you have done is hide the steps behind another function (part of the Smalltalk image I understand). I can do that too!

My conclusion at least is no significant advantage to Smalltalk (on this one).

Fair! :-)

[Michael] December 28, 2004 16:10:33.491

In case you were replying to me (Michael is overloaded :o):

I was just trying to show that Sriram's "problem" is unrelated to type systems per se. It's rather a problem of C#'s (un)expressiveness. The second sentence was just a joke ;-)

(This specific example seems more suited to functional style (I don't have to write \each -> applyFunction each) but I can simply write applyFunction -- would that work in a Smalltalk with first-class messages, or am I confused?), but I didn't intend to compare that against blocks or anything -- not up to that challenge yet, still recovering from the flu :o)

 Share Tweet This
-->