From: skaller <sk...@us...> - 2004-10-26 06:39:32
|
On Tue, 2004-10-26 at 15:52, Rhythmic Fistman wrote: > >CHANGE: line 2058 lpsrc/flx_lookup.ipk to read: > > > > if not (type_match syms.dfns d t2) then > > That's fixed the problem for me. > > Now I get > > CLIENT ERROR > LHS must be lvalue > In hw.flx: line 617, cols 3 to 40 > 616: var r: apoint; > 617: r.x = a.x + (i*(b.x - a.x))/MOVE_STEPS; > ************************************** > 618: r.y = a.y + (i*(b.y - a.y))/MOVE_STEPS; > > I suspect this is my problem. I've been ignoring whole lvalue thing up > until now. This code works: ------------------- struct X { m:int; }; var x = X(1); print x.m; endl; x.m = 2; print x.m; endl; --------------------- because the x.m notation desugars to get_m x where: get_m : lvalue[X] -> lvalue[int] Actually this seems wrong, since this should fail: print (X 1).m; but it doesn't, it works. It should be necessary to also generate: get_m : X -> int for get_m to accept a non-lvalue. Hmmm. In any case, it would seem you have written your own get_x method for apoint. You'll need to modify it to return an lvalue, here's an example: ----------------------------------------------------------- type Y = "Y" requires header "struct Y { int x; }; "; fun mkY: 1 -> Y = "0,Y()"; fun get_x: Y -> int = "$1.x"; // value overload fun get_x: lvalue[Y] -> lvalue[int] = "$1.x"; // lvalue overload var y = mkY(); get_x y = 1; print (get_x y); endl; y.x = 3; print y.x; endl; ------------------------------------------------------ -- John Skaller, mailto:sk...@us... voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net |