Author Topic: Gauche Scheme  (Read 15362 times)

0 Members and 1 Guest are viewing this topic.

RobbeK

  • Guest
Re: Gauche Scheme
« Reply #30 on: January 29, 2015, 12:45:38 PM »
Many thanks John  :)

Testing c-wrapper (ffi) ...                                     
testing bindings in #<module c-wrapper> ... ok
test dlopen, expects #f ==> ok
test dlsym, expects #f ==> ok
test ffi_prep_cif, expects 0 ==> ok
test ffi_call, expects 3 ==> ok
test ffi_closure, expects #t ==> ok
test call callback, expects 5 ==> ok
passed.
gerd@gerd-HP-Pavilion-dv4000-EK987EA-UUG:~/Downloads/c-wrapper-0.6.1/testsuite$ gosh inline-test.scm
Testing c-wrapper (inline) ...                                   
test constant, expects 1 ==> ok
test string, expects "foo" ==> ok
test ref array, expects 10 ==> ok
test func call without argument, expects (-2 -1 0 1 2) ==> ok
test func call with arguments, expects 3 ==> ok
test ref struct (. operator), expects 1 ==> ok
test ref struct (-> operator), expects 1 ==> ok
test post increment, expects 2 ==> ok
test post decrement, expects 1 ==> ok
test pre increment, expects 2 ==> ok
test pre decrement, expects 1 ==> ok
test unary plus, expects 1 ==> ok
test unary minus, expects -1 ==> ok
test unary logical negation, expects (0 1) ==> ok
test unary bitwise negation, expects -2 ==> ok
test unary reference, expects 123 ==> ok
test unary dereference, expects 456 ==> ok
test sizeof, expects #t ==> ok
test mul, expects 6 ==> ok
test divi, expects 3 ==> ok
test mod, expects 1 ==> ok
test add, expects 3 ==> ok
test sub, expects -1 ==> ok
test left shift, expects 4 ==> ok
test right shift, expects 2 ==> ok
test lesser than, expects (1 0 0) ==> ok
test greater than, expects (0 0 1) ==> ok
test lesser than or equal, expects (1 1 0) ==> ok
test greater than or equal, expects (0 1 1) ==> ok
test equal, expects (0 1 0) ==> ok
test not equal, expects (1 0 1) ==> ok
test bitwise and, expects 1 ==> ok
test bitwise or, expects 15 ==> ok
test bitwise xor, expects 14 ==> ok
test logical and, expects (1 0 0 0) ==> ok
test logical or, expects (1 1 1 0) ==> ok
test assign mul, expects 6 ==> ok
test assign div, expects 3 ==> ok
test assign mod, expects 1 ==> ok
test assign_add, expects 3 ==> ok
test assign_sub, expects -1 ==> ok
test assign left shift, expects 4 ==> ok
test assign right shift, expects 2 ==> ok
test assign bitwise and, expects 1 ==> ok
test assign bitwise or, expects 15 ==> ok
test assign bitwise xor, expects 14 ==> ok
test multi expr, expects 10 ==> ok
test while, expects 55 ==> ok
test while break, expects 55 ==> ok
test while continue, expects 55 ==> ok
test do while, expects 55 ==> ok
test do while break, expects 55 ==> ok
test do while continue, expects 0 ==> ok
test for, expects 55 ==> ok
test for noinit, notest, noupdate, expects 55 ==> ok
test for noinit, notest, expects 55 ==> ok
test for noinit, noupdate, expects 55 ==> ok
test for noinit, expects 55 ==> ok
test for notest, noupdate, expects 55 ==> ok
test for notest, expects 55 ==> ok
test for noupdate, expects 55 ==> ok
test offset, expects #t ==> ok
test not_supported, expects #t ==> ok
passed.



great ,  Rob

JRS

  • Guest
Re: Gauche Scheme
« Reply #31 on: January 29, 2015, 01:22:02 PM »
Can I assume this will keep you from drifting off to Lisp land?  :)



Our next challenge.  ;D
« Last Edit: January 29, 2015, 09:05:10 PM by John »

RobbeK

  • Guest
Re: Gauche Scheme
« Reply #32 on: January 30, 2015, 05:24:42 AM »
 :)

(Lisp took my breath and syntax away ...   )

In the mean time (newLisp comes without complex numbers and fractions) , I made a lib for doing this -- compiled it for Linux32 for the moment, but can compile into a DLL.
.. it uses the structure complex :::  double , double  ..  (it's based on the one from FreePascal/Lazarus)

if someone can use this to extend her/his code , just ask (it's around 130 Kb)  -- it even does logGamma (complex)
An example made with these a Mandelcrab based on Z^2.28 + C  -- graphics not optimized

best Rob

also attached the Gauche source (not exactly a fair compare , bigger window - around 1.6x (surface wise))

.
« Last Edit: January 30, 2015, 07:15:19 AM by RobbeK »

JRS

  • Guest
Re: Gauche Scheme
« Reply #33 on: January 30, 2015, 09:14:08 AM »
I think I like to original better.

.

RobbeK

  • Guest
Re: Gauche Scheme
« Reply #34 on: January 30, 2015, 01:41:12 PM »
Hi,

c-wrapper is working fine :  (wrote a little lib - doing the mean of two doubles )

gosh> (use c-wrapper)
#<undef>
gosh> (c-load-library "libmean.so.1.0.1")
#<undef>
gosh> (c-include "mean.h")
#<undef>
gosh> (mean 9.7 8.8)
9.25
gosh> (mean 9 8)
8.5

a lot of Scheme here : http://community.schemewiki.org/?scheme-faq-standards

best, Rob

JRS

  • Guest
Re: Gauche Scheme
« Reply #35 on: January 30, 2015, 02:15:13 PM »
An interpreter is useless without a C interface.  I'm glad c-wrapper worked out for you.

This reminds me of CERN ROOT in a twisted way.
« Last Edit: January 30, 2015, 11:14:40 PM by John »

RobbeK

  • Guest
Re: Gauche Scheme
« Reply #36 on: January 31, 2015, 12:32:02 PM »
Hi John,

Yes, but i'm not very familiar with C --  When young it was still B  ::)   -- and in Europe, Pascal was favored and educated.
Infact this may be better called a CFFI ; newLISP and Racket Scheme have more universal tools, and accept libs made with FreePascal etc ...

Racket Scheme seems to be in use with Boeing USAF , and while not a compiler - I think it is a very advanced tool with lots of interesting packages.  Maybe I'll switch into this one - runs under Win , Linux , MacOS

FFI works in a simple way :   from the screen Lib I made :

(require ffi/unsafe   ffi/unsafe/define)
 
 
 (define-ffi-definer mylib-define (ffi-lib "/usr/lib/libscreen2"))
 (mylib-define PIXEL (_fun _int _int _int _int _int  -> _void ))
 (mylib-define ENDSCREEN(_fun -> _void))
 (mylib-define SETSCREEN (_fun _int _int _int _int -> _ulong ))
 (mylib-define SCRCLR (_fun -> _void))
 (mylib-define SCRLOCK (_fun -> _void))
 (mylib-define SCRUNLOCK (_fun -> _void))
 (mylib-define SCR (_fun _int -> _void))
 (mylib-define SCRSLEEP (_fun -> _void))
 (mylib-define JULIA (_fun _double _double _double _double _int -> (_list-struct _int _double)))


compiles to executables and distributions - attached  (not the fastest graphics, if wanted i can directly poke into the frame's back buffer)

best Rob
 c  also  http://www.pawfal.org/fluxus/

.
« Last Edit: January 31, 2015, 12:39:51 PM by RobbeK »

JRS

  • Guest
Re: Gauche Scheme
« Reply #37 on: January 31, 2015, 12:45:14 PM »
Like it!

Now that you're on Linux, you have many more options to chose from without breaking the bank.

RobbeK

  • Guest
Re: Gauche Scheme
« Reply #38 on: February 01, 2015, 07:42:31 AM »
Yep, little Rob @ the candy store --   ::)

The code compiled for windows attached --  A distribution that should run without Racket being installed (tested on Wine and on an alien computer running win7   32bit )

Did not test the previous Linux distribution if working with Racket Scheme not installed -- looking for a way keeping the shared lib inside the package without having to install it into /usr/..

Code uses direct poking into the back buffer , and has a little animation.   

best, Rob

.

JRS

  • Guest
Re: Gauche Scheme
« Reply #39 on: February 01, 2015, 11:03:46 AM »
Quote
looking for a way keeping the shared lib inside the package without having to install it into /usr/..

Putting the .so library in the same directory as your executable should work as it is part of the search path. You can also use UPX to create a single file bundle to share.

Ran fine under Wine.

Note: Attached image name indicates this is a Gauche rendering when it's not. Sorry!

.
« Last Edit: February 01, 2015, 12:23:51 PM by John »

Mike Lobanovsky

  • Guest
Re: Gauche Scheme
« Reply #40 on: February 01, 2015, 11:41:47 AM »
Thanks Rob,

Looks good and works for me though somewhat slow; the animation runs at some 0.5 seconds per frame only.

RobbeK

  • Guest
Re: Gauche Scheme
« Reply #41 on: February 01, 2015, 12:59:39 PM »
Thanks , John , Mike

Yes rather slow , probably this is the "slow downer"   (still in Racket bytecode )

 
 (define (poke x y r g b)
   (let ((pos (* 4 (+ x (* 500 y)))))
     (ptr-set! ptr _byte pos b)
     (ptr-set! ptr _byte (+ pos 1) g)
     (ptr-set! ptr _byte (+ pos 2) r)))

ptr is the position of the back buffer , but for one frame this has to be ran 250000 times -- much better will be to include it into the main calculation routine and increasing the address  by 4bytes every cycle   (p += 4 in basic)  , here pos is just an offset to the base address ptr.  There may be a problem (due to the modern OOP way of thinking --   ptr is an object , not a number (it is a cpointer) )  , i still have to use the pointer and the offset separated , while it is in fact just a number.   Very often objects do the opposite of their (raison d'ĂȘtre) reason of existence , they make coding difficult and  result slow execution time -- Racket Scheme goes that far that even a color is an object (make-object color% etc ... ) and then you need methods getting a color / rgb channel of a color etc ...   

(define gray (send the-color-database find-color "gray"))     :'(

 
"O TEMPORA O MORES"  ;)

best , Rob

(i'll replace this uselessness  by adding in my FreePascal generated LIB   --    poke (scrptr + pos , ubyte) --  simple as that, no need to make things more complicated than they are )

   
(when (agree?)
      ( defmacro I() 'we ))

« Last Edit: February 01, 2015, 01:26:33 PM by RobbeK »

JRS

  • Guest
Re: Gauche Scheme
« Reply #42 on: February 01, 2015, 10:32:16 PM »
Rob,

Would it be difficult to create a rose using the Julia direction your using currently?

While you're thinking about it, here is another Julia Rose.



John
« Last Edit: February 02, 2015, 12:06:15 AM by John »

Mike Lobanovsky

  • Guest
Re: Gauche Scheme
« Reply #43 on: February 02, 2015, 05:38:37 AM »
Will this one do? :)




It's an OpenGL sample script from a regular FBSL installation. It's purely procedural, i.e. there is no 3D model behind it; everything in it is calculated in real time.

JRS

  • Guest
Re: Gauche Scheme
« Reply #44 on: February 02, 2015, 10:25:50 AM »
I can almost smell it and no thorns which was surprising.  ;D

Thanks Mike.