I have some trouble with this, I found this note:
| DCL_newtype t ->
(* Add the newtype to the sym_table. *)
add_symbol ~pubtab ~privtab symbol_index id (SYMDEF_newtype t);
(* Create an identity function that doesn't do anything. *)
let piname = TYP_name (sr,id,[]) in
(* XXX: What's the _repr_ function for? *)
let n_repr = Flx_mtypes2.fresh_bid counter_ref in
(* Add the _repr_ function to the symbol table. *)
add_symbol ~pubtab ~privtab n_repr "_repr_" (SYMDEF_fun (
...
(* Add the _make_ function to the sym_table. *)
add_function priv_name_map ("_make_" ^ id) n_make;
Answer:
module X {
open C_hack;
type pi = new int * int;
fun fst(x:pi):int => (_repr_ x).(0);
fun snd(x:pi):int => (_repr_ x).(1);
fun mkpi(x:int,y:int):pi=>_make_pi(x,y);
The _repr_ thing grants access to a Felix abstract type's definition.
For a type "pi" here, _repr_pi is a *private* function of the module X.
This allows us to define accessor functions to abstract type pi in module
X but not outside module X, thus providing information hiding.
Similarly a "make_pi" function is provided to actually construct
a value of that type. I may get rid of this, now we have "ctor",
since that can make a value using just _repr I think.
At present it seems these things do not work with polymorphism.
I need to fix that because "darray" requires this feature,
otherwise
d++
is interpreted as incrementing its representation as well as itself,
and the representation happens to be a pointer which can be
incremented .. leading to an ambiguity. Hiding the representation
will resolve the ambiguity.
--
john skaller
[email protected]
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and,
should the need arise, upgrade to a full multi-node Oracle RAC database
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language