something like Clojure's "doto"?

View: New views
2 Messages — Rating Filter:   Alert me  
< Prev | 1 - 2 | Next >

Re: something like Clojure's "doto"?

by Daniel Sobral :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'd rather just use { import context => }, as import is already a keyword.

On Sat, Jul 18, 2009 at 12:35 PM, Alex Boisvert <boisvert@...> wrote:
An alternative syntax for importing arguments could be,

{ |CONTEXT| =>
    BODY
}

as syntactic sugar for,

{ CONTEXT =>
    import CONTEXT._
    BODY
}

with the possibility of importing n arguments,

{ x, |y|, |z| => /* imports y._ and z._ but not x._ */ }

or without naming the argument,

{ |_| =>  /* imported argument remains unnamed */ }

and with explicit types,

{ |x: Foo|, |y: Bar| =>  ... }

alex
(with apologies to the Ruby syntax)




--
Daniel C. Sobral

Something I learned in academia: there are three kinds of academic reviews: review by name, review by reference and review by value.

Re: something like Clojure's "doto"?

by Chris Twiner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

that doesn't do the same thing however.

{ import _._ }

looks pretty strange though.

This was the good thing about the import syntax ( {: or indeed |x| )
you could do both an import of members (default behaviour) or use it
to thread implicits.

On Sat, Jul 18, 2009 at 11:07 PM, Daniel Sobral<dcsobral@...> wrote:

> I'd rather just use { import context => }, as import is already a keyword.
>
> On Sat, Jul 18, 2009 at 12:35 PM, Alex Boisvert <boisvert@...>
> wrote:
>>
>> An alternative syntax for importing arguments could be,
>>
>> { |CONTEXT| =>
>>     BODY
>> }
>>
>> as syntactic sugar for,
>>
>> { CONTEXT =>
>>     import CONTEXT._
>>     BODY
>> }
>>
>> with the possibility of importing n arguments,
>>
>> { x, |y|, |z| => /* imports y._ and z._ but not x._ */ }
>>
>> or without naming the argument,
>>
>> { |_| =>  /* imported argument remains unnamed */ }
>>
>> and with explicit types,
>>
>> { |x: Foo|, |y: Bar| =>  ... }
>>
>> alex
>> (with apologies to the Ruby syntax)
>>
>
>
>
> --
> Daniel C. Sobral
>
> Something I learned in academia: there are three kinds of academic reviews:
> review by name, review by reference and review by value.
>
< Prev | 1 - 2 | Next >