Skip to content

investigate how to create js class in ocaml #149

@bobzhang

Description

@bobzhang

it still makes sense to allow create js classes in ocaml, we can do functional object oriented programming, the benefit is that methods are attached to object, think about it, if we want to
customize comparison behavior for int64, one possible way is below (tricky parts like how to handle this etc)

currently we can do this

function Int64(lo,hi){
   this.lo = lo;
   this.hi = hi; 
}
Int64.prototype.compare = ..
class type t = object
   method lo__r : nativeint 
   method hi __r : nativeint
   method compare__2 :  t -> int 
end
external create : nativeint-> nativeint -> t = "Int64" [@@js.new]
external compare :  t -> t -> int = "compare" [@@js.send]

It would be nice that we can do it all in ocaml

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions