This code source don t compile, Is there a way to make that in OPA ?
type User = { nom : string ; prenom : string }
un_user = { nom = "My_name" ; prenom = "My_last_name" } : User
champ = "nom"
do jlog(un_user.`champ`)
This code source don t compile, Is there a way to make that in OPA ?
type User = { nom : string ; prenom : string }
un_user = { nom = "My_name" ; prenom = "My_last_name" } : User
champ = "nom"
do jlog(un_user.`champ`)
Runtime magic is possible in Opa, using the OpaValue module which contains feature for runtime introspection of values (not type safe)
http://opalang.org/resources/doc/index.html#opavalue.opa.html/!/value_stdlib.core.OpaValue.Record
But this is not for casual user, and a very dangerous coding style. It is often a need coming from code written in a coding style corresponding to scripts and runtime evaluated language.
I m not sure what you re trying to do... if to print the nom field of un_user
then you can do:
do jlog(un_user.nom)
if you really want to access record field with a dynamic name, then this cannot be done in Opa (AFAIK).
I m just investigating OPA and trying to make the leap from a traditional LAMP background, so here s my first of many newbie questions: Can I have two OPA apps sharing the same database, say one ...
I ve used List.exists( ), i woudl like to know if there is an equivalent for Db. If i have a function f(e) : bool, i would like to know if there is at least one element e, with f(e) -> true. ...
example: type person = { name : string ; age : int } db /person : intmap(person) I know how to get a single person from the db, but how do I get them all? and print ...
I notice that included in the source of the OpaWhiteBoard example, there is a .ml file here: https://github.com/hhugo/OpaWhiteBoard/blob/master/src/opacairo/cairo.ml This appears to be OCaml with ...
Is it possible to access HTML5 canvas elements in Opa?
This code source don t compile, Is there a way to make that in OPA ? type User = { nom : string ; prenom : string } un_user = { nom = "My_name" ; prenom = "My_last_name" } : User champ = "nom" do ...
I have seen in the stdlib and in some github project. Code like that : MyClass = field_id(id) = "{id}_field" {{ my_func(args) = output }} What the interest to have function before the {{ }} ...
In MLState s new programming language Opa, is it possible to create a global variable?