[squeak-dev] Extracting argument names from a block

Eliot Miranda eliot.miranda at gmail.com
Mon May 21 23:40:23 UTC 2012


Frank,

   is this close enough?

[:a :block :with :args|] decompile arguments collect: [:ea| ea key] #('a'
'block' 'with' 'args')

Not symbols, but strings.

On Mon, May 21, 2012 at 2:27 PM, Frank Shearar <frank.shearar at gmail.com>wrote:

> On 21 May 2012 22:00, Bert Freudenberg <bert at freudenbergs.de> wrote:
> > On 21.05.2012, at 22:47, Frank Shearar wrote:
> >
> >> Without having to decompile a block, how may I find the names of a
> >> block's arguments?
> >>
> >> In other words, given
> >>
> >>     [:a :b :c | "stuff"]
> >>
> >> I'd like to extract #(a b c).
> >>
> >> (Failing that, I'll have to live with myBlock decompile arguments
> >> collect: [:a | a name asSymbol]).
> >>
> >> frank
> >
> > I don't know (I'm even surprise the decompiler knows) - but can you say
> a little bit more for what you would need that?
>
> Sure! I'm working on a miniKanren-like logic programming
> language/framework. Typically in a miniKanren clone there's a macro
> called "fresh" that introduces logic variables. For instance,
>
> (fresh [x y]
>  (== [x y] [1 5]))
>
> introduces two logic variables called x and y, and then unifies [x y]
> with [1 5] to give the substitution/most general unifier x -> 1, y ->
> 5.
>
> So I thought I could do something like
>
> [:x :y | {x. y} unifyWith: #(1 5)] fresh
>
> where BlockClosure >> #fresh currently looks like this:
>
> fresh
>        ^ self valueWithArguments: (self decompile arguments collect: [:a |
> a
> name asSymbol]).
>
> frank
>
> > - Bert -
> >
> >
> >
>
>


-- 
best,
Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20120521/e92e2fb0/attachment.htm


More information about the Squeak-dev mailing list