Symbol should implement #cull:cull:...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Symbol should implement #cull:cull:...

Steven Kelly

Hi,

 

Since VW 7.7, Symbol works nicely as a replacement for unary blocks by implementing #value:, and can take part in the neat #cull: mechanism. However, it doesn’t implement #cull:cull:, so if it is used as a block-like argument in a place that can supply an ‘optional’ 2nd argument to the block, it gives an error.

 

Implementing cull:cull: and cull:cull:cull: to match cull: would correct this.

 

All the best,

Steve


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Symbol should implement #cull:cull:...

Steffen Märcker
I second this. In fact, I implemented the evaluation protocol in Symbol  
for testing purposes. Please find my code is attached. Note that I use a  
new message #arity that answers the number of arguments required to  
evaluate a symbol/block. The package provides the following methods:

BlockClosure
   >>arity

Symbol
   >>arity
   >>cull:cull:
   >>cull:cull:cull:
   >>cullWithArguments:
   >>value:value:
   >>value:value:value:
   >>valueWithArguments:

Regards,
Steffen


Am 07.05.2014, 12:52 Uhr, schrieb Steven Kelly <[hidden email]>:

> Hi,
>
>
> Since VW 7.7, Symbol works nicely as a replacement for unary blocks by
> implementing #value:, and can take part in the neat #cull: mechanism.
> However, it doesn't implement #cull:cull:, so if it is used as a  
> block-like
> argument in a place that can supply an 'optional' 2nd argument to the  
> block,
> it gives an error.
>
>
> Implementing cull:cull: and cull:cull:cull: to match cull: would correct
> this.
>
>
> All the best,
>
> Steve
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

CullForSymbols.st (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Symbol should implement #cull:cull:...

Reinout Heeck-2
I would also like to see these in base.

The implementation you posted is a copy of the Cincom algorithm which re-computes the number of arguments of the compiled block for every argument that needs to be dropped. In the case of symbols repeatedly computing the arity seems rather expensive, so I see some potential for optimization there :-)


R
-



On 5/8/2014 7:23 PM, Steffen Märcker wrote:
I second this. In fact, I implemented the evaluation protocol in Symbol for testing purposes. Please find my code is attached. Note that I use a new message #arity that answers the number of arguments required to evaluate a symbol/block. The package provides the following methods:

BlockClosure
  >>arity

Symbol
  >>arity
  >>cull:cull:
  >>cull:cull:cull:
  >>cullWithArguments:
  >>value:value:
  >>value:value:value:
  >>valueWithArguments:

Regards,
Steffen


Am 07.05.2014, 12:52 Uhr, schrieb Steven Kelly [hidden email]:

Hi,


Since VW 7.7, Symbol works nicely as a replacement for unary blocks by
implementing #value:, and can take part in the neat #cull: mechanism.
However, it doesn't implement #cull:cull:, so if it is used as a block-like
argument in a place that can supply an 'optional' 2nd argument to the block,
it gives an error.


Implementing cull:cull: and cull:cull:cull: to match cull: would correct
this.


All the best,

Steve


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Symbol should implement #cull:cull:...

Steffen Märcker
You're right, it is not optimized at all. That code was just a simple  
solution I needed once. =) If anyone is interested, I'll happily provide a  
more polished package to the public repo.

Btw, does anyone use curried blocks (e.g. via the BlockCurrying package)?

Regards,
Steffen

Am 12.05.2014, 10:51 Uhr, schrieb Reinout Heeck <[hidden email]>:

> I would also like to see these in base.
>
> The implementation you posted is a copy of the Cincom algorithm which
> re-computes the number of arguments of the compiled block for every
> argument that needs to be dropped. In the case of symbols repeatedly
> computing the arity seems rather expensive, so I see some potential for
> optimization there :-)
>
>
> R
> -
>
>
>
> On 5/8/2014 7:23 PM, Steffen Märcker wrote:
>> I second this. In fact, I implemented the evaluation protocol in
>> Symbol for testing purposes. Please find my code is attached. Note
>> that I use a new message #arity that answers the number of arguments
>> required to evaluate a symbol/block. The package provides the
>> following methods:
>>
>> BlockClosure
>>   >>arity
>>
>> Symbol
>>   >>arity
>>   >>cull:cull:
>>   >>cull:cull:cull:
>>   >>cullWithArguments:
>>   >>value:value:
>>   >>value:value:value:
>>   >>valueWithArguments:
>>
>> Regards,
>> Steffen
>>
>>
>> Am 07.05.2014, 12:52 Uhr, schrieb Steven Kelly <[hidden email]>:
>>
<---Schnitt--->
>>
>>
>> _______________________________________________
>> vwnc mailing list
>> [hidden email]
>> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc