<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<meta content="text/html; charset=UTF-8">
<style type="text/css" style="">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p>Hi Tobias, thanks for your input!</p>
<p><br>
</p>
<p>> <span style="font-size:12pt">Why not simply</span></p>
<div>>         Matrix rows: 5 columns: 6 tabulate: [:x :y | x @ y]</div>
<div>> </div>
<div>> What's wrong with blocks?</div>
<div><br>
At least in scripting scenarios, they cost extra redundant characters. Symbol >> #value:value: is a known selector (at least now), so why should I always type all these redundant letters?</div>
<div><br>
</div>
<div>> <span style="font-size:12pt">A symbol should not answer to an #value: … #value:value:...</span>
<div><br>
</div>
<div>Levente should know it, he implemented Symbol >> #value:value:.</div>
<div>However we solve this, I think, at the moment, we have an irritating inconsistency. Imho, Symbol >> #value: is not better than Symbol >> #value:value at all. And I use it every day, so I would vote for increasing the support. (BalloonMorph allInstancesDo:
 #abandon, SystemWindow select: #isInWorld, ...)</div>
<div><br>
</div>
<div>> <span style="font-size:12pt">I would then rather use withIndexCollect. It does what it says on the tin.</span>
<div><br>
</div>
<div>At the moment, we have #collect: and #withIndexCollect: side by side. However, their implementations are almost equal, and my problem is that every method that I write to access a collection (e. g. collection accessors) can only support one of them. Why
 not exploit the fact that [:x :i | x + i] and [:x | x squared] can be distinguished by #numArgs and unify these two accessors?</div>
<div><br>
</div>
<div>> <span style="font-size:12pt">you can use cull:cull: anyways.</span>
<div><br>
</div>
<div>Interesting point. This would also simplify the approaches for our recent #to:collect: issue:</div>
<div>(1 to: 5) collectX: [Color random]</div>
<div><br>
</div>
<div>Could we maybe just adapt SequenceableCollection >> #collect: to support 0 - 2 block arguments instead of exactly one? It would be nice to have this in Trunk!</div>
<div><br>
</div>
<div>
<div>> > Symbol >> #asBlock</div>
> <span style="font-size:12pt">that's not too bad :D</span>
<div>> but there is already perform:withArguments:, so this should be simpler?</div>
<div><br>
</div>
<div>I would be glad to send something to the Inbox. But how do you create a block by reflection, without knowing the number of arguments?</div>
<div>It looks as if there is no public interface yet and I would have to generate the byte codes manually. Or am I overlooking something?</div>
<div><br>
</div>
<div>Best,</div>
<div>Christoph</div>
</div>
</div>
</div>
</div>
<p></p>
<div id="x_Signature">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<div name="x_divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<div><font size="2" color="#808080"></font></div>
</div>
</div>
</div>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>Von:</b> Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von Tobias Pape <Das.Linux@gmx.de><br>
<b>Gesendet:</b> Montag, 16. Dezember 2019 13:41:03<br>
<b>An:</b> The general-purpose Squeak developers list<br>
<b>Betreff:</b> Re: [squeak-dev] String >> #numArgs</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">Hi<br>
<br>
> On 16.12.2019, at 13:18, Thiede, Christoph <Christoph.Thiede@student.hpi.uni-potsdam.de> wrote:<br>
> <br>
> Hi all! :-)<br>
> <br>
> > Woah! This works? When and why is this useful? Does anybody recall the prime example? :-) #inject:into:?<br>
> <br>
> Yes, I believe I once used it with #inject:into:, but I don't remember. What prime example are you referring to? :)<br>
> My personal favorite is:<br>
> Matrix rows: 5 columns: 6 tabulate: #@ "for quickly setting up an example matrix :-)"<br>
<br>
Why not simply <br>
        Matrix rows: 5 columns: 6 tabulate: [:x :y | x @ y]<br>
<br>
What's wrong with blocks?<br>
<br>
> <br>
> I find it rather confusing that the following does not work:<br>
> #raisedTo: value: 2 value: 3. "works"<br>
> #raisedTo:modulo: value: 2 value: 3 value: 4. "does not understand"<br>
> This is an inconsistency.<br>
<br>
Yes. The first case should also bail.<br>
<br>
A symbol answering to #perform: is IMHO borderline.<br>
A symbol's answer to #value should be itself.<br>
A symbol should not answer to an #value: … #value:value:...<br>
<br>
<br>
> <br>
> @Eliot:<br>
> > Can you give some examples of where you find you are needing to do this?<br>
> <br>
> Actually, I was trying something like this:<br>
> SequenceableCollection >> #collectX: aBlock<br>
> ^ aBlock numArgs = 2<br>
> ifTrue: [self withIndexCollect: aBlock]<br>
> ifFalse: [self collect: aBlock]].<br>
> <br>
> Now you can say:<br>
> #(1 2 3) collectX: [:x | x squared].<br>
> #(1 2 3) collectX: #squared.<br>
> #(1 2 3) collectX: [:x :i | x + i].<br>
<br>
That's hacky.<br>
<br>
I would then rather use withIndexCollect. It does what it says on the tin. <br>
<br>
> But the following does not work:<br>
> #(1 2 3) collectX: #+.<br>
> <br>
> Maybe I would rather need something like #value:cull: for an optional second argument?<br>
> <br>
<br>
you can use cull:cull: anyways.<br>
<br>
> In general, from the point of scripting convenience, I would love Symbol to support many more protocols of BlockClosure. What about:<br>
> Symbol >> #asBlock<br>
> ^ self numArgs caseOf: {<br>
> [0] -> [[:rcvr | rcvr perform: self]].<br>
> [1] -> [[:rcvr :arg | rcvr perform: self with: arg]].<br>
> [2] -> [[:rcrv :arg1 :arg2 | rcrv perform: self with: arg1 with: arg2]].<br>
> ... }<br>
> <br>
that's not too bad :D<br>
but there is already perform:withArguments:, so this should be simpler?<br>
<br>
Best regards<br>
        -Tobias<br>
<br>
</div>
</span></font>
</body>
</html>