|Newbie questions about Pliant
various questions and shootout
|Message posted by pixel on 2001/04/20 23:16:30
|I've started coding the examples found in
http://www.bagley.org/~doug/shootout/craps.shtml, to discover the language and
also to compare the performance. As for now performance is quite good :)
eg: for dumb fibonacci, the speed is C < pliant < ocaml (poor C!)
If someone could have a look at the code, and if i code enough of them, i could
ask doug to add pliant to the list.
As for now i only have: ftp://ftp.mandrakesoft.com/pub/pixel/pliant
Now a few questions:
- the following is working:
> "z1" parse "z" (gvar Int i)
> console i eol
> "1" parse "" (gvar Int i)
> console i eol
> seems to be a bug at /pliant/language/type/text/str.pli (internals) 449 3
> execute file:parse.pli (internals) 4 1
- What i wanted to achieve is getting the number out of argv.
Is this the simplest way?
> gvar Str s_n := cast ((pliant_script_args translate Address 1) map CStr) Str
> if (s_n parse "z" (gvar Int n))
- sample/inherit.pli gives
Failed to compile implementation ('define_field' ? ? ? ?)
- how to access stdin?
- the forum removes empty lines in "Simple text" :'-(
thanks, cu Pixel.
|Message posted by maybe Hubert Tonneau on 2001/04/21 09:00:33
|About your benchmarks:
. A sample such as Fibonacci is not meaningfull because the function is too
short, so the result is very unstable: a small change in the code generator
may provide a big change in the end result number.
I'd also rather test the function in the so called interpreter as:
function fibo n -> r
arg Int n r
if n < 2
r := 1
r := (fibo n-2) + (fibo n-1)
function test n -> r
arg Int n r
var DateTime start := datetime
r := fibo n
var DateTime stop := datetime
console "ellapsed time: " stop:seconds-start:seconds eol
. If you test Pliant, then you have to test it twice:
First when using the built in code generator
(install Pliant through typing /pliant/pliant/install/install)
Second when using GCC as the code generator
(install Pliant through typing /pliant/pliant/install/install gcc)
On such a small sample as Fibonacci, the result when using GCC as as
the code generator can be a bit better than C because the register
calling convension Pliant uses is better than the default GCC one.
Also you can get the same speed improvement in C if you change the
calling convension at GCC revel.
|Message posted by maybe Hubert Tonneau on 2001/04/21 09:01:46
|About your parsing problem.
you should simply write:
"1" parse (gvar Int i)
|Message posted by pixel on 2001/04/21 11:37:36
|> About your benchmarks:
> . A sample such as Fibonacci is not meaningfull because the function is too
> short, so the result is very unstable: a small change in the code generator
> may provide a big change in the end result number.
it is well known that those small benchmarks are not good benchmarks. *but* they
give anyway a speed factor. For example perl is 100 times slower than C on this,
which is huge and means something even if the benchmark is stupid.
> . If you test Pliant, then you have to test it twice:
> First when using the built in code generator
> (install Pliant through typing /pliant/pliant/install/install)
> Second when using GCC as the code generator
> (install Pliant through typing /pliant/pliant/install/install gcc)
i've tried and got the following pbs:
- pliant doesn't get the right error code for
"gcc -O2 -m486 ... -o /dev/null ..."
The return status from os_waitpid is nonsense. It seems like the cloning
(os_clone) is the pb. I don't understand how you use the clone syscall, which
expects a function as the first argument?...
- forcing use_kernel_functions to false, the ./make-linux-i386-gcc succeeds, but
the .exe generated is unusable: i get some "illegal hardware instruction"
i'll try again with a clean tarball though.
|Message posted by pom on 2001/04/21 13:16:49
|To read things from stdin, you may use:
var Str s := keyboard_input "Enter a string "
|Message posted by pom on 2001/04/21 13:23:18
|There is a small bug in the sample:
line 24, instead of
implementation define_field f:type f:name f:initial_value f:options
it should be
implementation define_field f:type f:name f:initial_value
as define_field has only 3 args.
|Message posted by maybe Hubert Tonneau on 2001/04/21 13:43:18
|Looks like GCC interface is currently broken (I don't know when I broke it).
I'll try to correct it for the soon to come release 59.
|Message posted by pixel on 2001/04/21 14:00:02
|> it should be
> implementation define_field f:type f:name f:initial_value
> To read things from stdin, you may use:
> module "/pliant/language/ui/ansi_terminal.pli"
> var Str s := keyboard_input "Enter a string "
not really what i want. i just want a Stream based on file descriptor 0...
|Message posted by maybe Hubert Tonneau on 2001/04/21 22:27:34
|If you want a 'Stream' to stdio (Unix handle 0), then you need release 59
(not published yet )-: ), then include module /pliant/language/stream/pipe.pli
and open the stream with name 'handle:0'