On 16/02/2013, at 5:47 PM, john skaller wrote:

>       * (lhsp) = rhs
> 
> is equivalent to
> 
>       lhsp <- rhs

Unfortunately this only works for pointers type &T.
It doesn't work for carrays.

The problem is that a carray[T] = +T is an abstraction.
It has get and set methods:

        get (a, i)
        set (a,i,v)

You can also advance the array:

        a + i

Now, at the moment there's also

        lvalue fun deref[T] : carray[T] -> '$1[$2]'

Really this shouldn't be an lvalue, rather

        *a == get(a,0)

With that, we cannot store at the pointer except with set method.
Even this will not work:

        a <- v

because a has type +T and not &T as required. Now we also have
this nasty thing:


  //$ Demote carray to Felix pointer (safe unless off the end).
  fun -[T]: carray[T] -> &T = "$1"; // safe (unless we allow +T to be NULL 
later ..)

so we could write:

        -a <- v

and even 

        -(a + i) <- v

Now, for arrays (type T ^ N) we have

         a. i 

to fetch the i'th element.  We can write:

        (&a) .  i <- v

because application of a integer is not only a fetch
of the i'th element of an array, it is also a calculation
of the address of that element given the address of the array.

[So, we have something beautiful: if a is an array of T,
the (&a) is an immutable array of &T]

However, since we have no lvalues, we cannot easily write:

        a . i  = v

Even if the translation to

        (&a) . i = v

works for an array (T^N) it doesn't work for a carray:
a carray (+T) is already a pointer, it cannot be addressed.


--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, 
is your hub for all things parallel software development, from weekly thought 
leadership blogs to news, videos, case studies, tutorials, tech docs, 
whitepapers, evaluation guides, and opinion stories. Check out the most 
recent posts - join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to