Newbie questions about Pliant

Newbie questions about Pliant

various questions (bis)

Message posted by pixel on 2001/04/21 14:52:40
I've just succeeded writing the "method call" test of doug's shootout. The
inherit meta is working great (i don't say i've understood it, but i like the
concept :)
.
- what is the difference between arg_w and arg_rw? it seems like a convention
"arg" implies "it won't be modified", but "arg_w" doesn't check "is not
accessed"?
.
- can the "build" function takes argument? (think C++ constructor)
.
- is there a way to have ``protected'' or ``private'' fields? or to have an
abstract type?
.
How hard would it be to have the following features
- "each" on List and Array
- typed List's
- if-else return a value (a la fonctional programming) instead of Void
- have an here array/list, like ``@l = ('a', 'b', 'c')'' in perl
Message posted by pom on 2001/04/21 17:52:16
  • arg_w specifies an argument which value is not used (for optimization) an hence that the result is independant of this value (for constant evaluation)
  • build cannot have arguments (was a long discussion one year ago). This way, it is always possible to call build without any further info (like when you construct an Array).
  • if you use 'inherit' meta, protected or private fields are fields you do not copy. It would necessite some patch and some additional infos in Type type. Otherwise, when you define a type in a module, you may choose not to export all the fields or methods.
  • each meta should be added soon for all set types (not very difficult); should be added in a Todo list.
  • typed Lists already exist (see doc on data sets) although the core machinery uses untyped ones.
  • a if-else returning a value exists: this is shunt (shunt cond1 value1 cond2 value2 ... condn valuen valuelast) returns
    • value1 if cond1
    • else value2 if cond2
    • else ..
    • else valuen if condn
    • else valuelast.
    the type used is the first type of the one of value1,...,valuelast which can be used to cast all the other values.
  • I did a meta to fill a set with key/value pairs. I put it in the Code forum. it works the following (I used it for Dictionary):
    gvar (Dictionary Str Char) 'C escape chars'
    fill 'C escape chars'
      "\a"  character:7
      "\b"  character:8
      "\f"  character:12
      "\n"  "[lf]"
      "\r"  "[cr]"
      "\v"  character:11  
    
    I should adapt the meta for simple value lists (to be added on todo list...)
Message posted by pom on 2001/04/23 16:27:13
remark: for typed lists, you have to link to the module "/pliant/language/unsafe.pli"
Message posted by pom on 2001/04/23 16:46:46
I've added a fill for Lists and Arrays (see code forum)