I recently changed the parser to ensure:

  x[sfactor_pri] := x[sfactor_pri] "*." sthe_name =># "`(ast_dot ,_sr 
((ast_deref ,_sr ,_1) ,_3))";
  x[sfactor_pri] := x[sfactor_pri] "&." sthe_name =># "`(ast_apply ,_sr (,_3 
(ast_ref ,_sr ,_1)))";


The first one should actually read like the second. In Felix notation

        p*b == (*p).b
        a&.b == (&a).b

If b is a projection of a product (tuple, struct, record, array) then

        (*p).b == *(p.b)

Ok, so here's the problem. With any ArrayObject such as varray i have 
overloaded &. to mean

    fun unsafe_get_ref: varray[v] * size -> &v = "$1+$2";

which is invoked by

  fun n"&." [I in ints] (x:t, i:I) : &v = {
    assert i.size < x.len; 
    return unsafe_get_ref (x,i.size); 
  }

but this overload no longer works.

So here's my problem: Classes cannot say 

        "for all products. p&.b means &p.b"

What I mean is you would have to overload, manually, EVERY product
you use: tuples, records, etc etc. you can use a class to do this for 
arrays though. I had done that. But it isn't acceptable that records
and tuples work the same way.

Here's a related issue. For any value type, if you put it in a variable
it is mutable. In particular its *components* should be mutable.
[This is only product types, not functions and at the moment not
unions]

That comes from the compiler support, every projection the
compiler generates for a value extraction:

        v.proj

is overloaded to also provide a pointer extraction:

        (&v).proj

The problem comes with things like varray, and darray, and other
mutable data structures.

Because these data structures are effectively pointers .. in the case
of a varray recall a varray is *precisely* just a pointer to a C array
(with length monitored by the GC), you can store a value or extract
a pointer from a varray VALUE. It doesn't need to be put into a variable.

One has to think that a varray IS a pointer, or at least like one, 
to proceed.

Whatever problems this causes for the programmer conceptually,
they will get a lot worse if we can't use familiar notation.

Many data structures provide get_ and set_ method. 
This solves the problem for whole elements. 

Unfortunately with composed data types, get/set is useless.
Just think of

        // extract 3 deep into product type:
        var v0 = a.get i0;
        var v1 = v0.get i1;
        var v2 = v2.get i2;

        // modify component
        set (&v2,i3 newval);

        // now put it back in place in higher components
        set(&v1,i2,v2);
        set(&v0,i1,v1);
        set(a,i0,v0);


In C++ this is just

        a.i0.i1.i2.i3 = newval;

I hope the problem is clear. For value types you have to store in
a variable to get a pointer:

        &v

Recall & is NOT an operator. It's just a way of saying the name of the
address of a variable.

So the concept is

        v&.p

means

        (&v).p

for a product, but

        get_ref (v,p) // returns an actual pointer

for an abstract data type which "is" a pointer, i.e. any value
which represents a mutable data structure.

The problem is "get_ref" can't work with a variable.
        
--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and 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