« Return to Thread: Io N00B - basic questions

Re: Io N00B - basic questions

by Jeremy Tregunna-2 :: Rate this Message:

Reply to Author | View in Thread

::= is an operator for newSlot() which creates a setSlot which takes  
an argument and sets the value on the slot. While that doesn't make a  
lot of sense, consider this:

foo := 42

Creates a single slot, "foo" with the value 42.

Consider:

foo ::= 42

Creates a slot called "foo" with the value 42, and creates a "setFoo"  
which takes a single argument, the value to update the "foo" slot with.

The difference between @ and @@ is that @ returns a Future and fires  
off a coro into the "background". Consider:

blurgle := @bar

whatever bar is will be run in a coro and a future will be immediately  
returned to blurgle. If you access blurgle (lookup that slot) before  
bar is done running, the coro will pause and wait for bar to finish  
before returning the result.

If you run:

blurgle := @@bar

What will happen is blurgle will be nil immediately, and when you  
access blurgle you'll get nil until bar is finished running then  
you'll get the value of whatever bar evaluated to.

I hope this is clear.

On 21-Apr-09, at 10:36 AM, HowardP wrote:

>
>
> HI all,
>
> I've read most of the docs on Io, but am still unclear about these  
> two items:
>
>
> What's the difference really between
>
> ::=
>
> and
>
> :=
>
> The ' := ' is obvious, ' ::= ' not so.
>
>
> And what's the difference between the coroutine syntax of
>
> @thing
>
> and
>
> @@thing
>
>
> thank you for the assistance,
>
>
> GO IO !
>
>
>

Regards,

Jeremy Tregunna
jeremy.tregunna@...



 « Return to Thread: Io N00B - basic questions