Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - konrad

#1
Anything else we might add? /
September 17, 2007, 09:14:06 PM
Quote from: "Jeff"It's not too difficult to use the built in functionality.  Simply scanning for function prototypes should be sufficient.  It's not like FFIs in CL where you have to map each type to a newLISP type.



Typically, if you need regular access to data in a composite C type, you would define a function that accepts a pointer to the struct and use unpack or get-foo functions to pull the data out that you need.


The biggest issue is when you need to allocae memory for the data structure ahead of time, and there is a lot of functions which expect the caller to do the memory allocation and pass in addresses to be written to.
#2
Anything else we might add? / Parsing C Header Files
September 16, 2007, 06:36:34 PM
Is anyone trying to parse C header files to auto-import modules. what the build in (import ...) function does is a good start but not generally sufficient as in addition to functions most C libraries also expose a large number of constants and structure definitions, in some cases using preprocessor Macros as well.



for completely smooth use of C libraries it would be handy to parse this stuff out and auto create it inside a lisp Context. removing annoying prefixes would also be handy : ).  Note one common pattern which is currently awkward from newlisp is where the calling code is expected to reserve memory for a complex structure and pass its address into the function.



I have to admit that my C foo is rather weak but this is a project I'm interested in., and would rather not re-invent the wheel if someone is already working on it.



regards



Konrad.
#3
newLISP in the real world / Now for the next line
September 13, 2007, 10:18:41 PM
Well that works. The next trick is to capture events. Not to do this the C code



1) creates a variable based on a structure

2) passes the address of the structure into a function so it can be written too.



I assume that I need to



(set 'ev (pack ...))



to get a correct event symbol and then I need to unpack the results for reading?



would this be about the correct take on this ?



I have a feeling this is going to be a little clunky as the C definition contains a union.



regards



Konrad.
#4
newLISP in the real world / Oops.
September 13, 2007, 04:53:41 PM
Yes Er that will be it.



I don't know how many times i've spend ages trying to debug a typo,



so here is another example. dp is what I had meant to xall the variable not db. Using longer names like display would have probably saved me on this one : )



regards



Konrad
#5
newLISP in the real world / newlisp code
September 11, 2007, 08:13:15 PM
Here is my code:



(context 'CUCUL)
(set 'libcucul "/usr/lib/libcucul.so")
(set 'funcs '(
             "cucul_create_canvas"
             "cucul_set_color_ansi"
             "cucul_putstr"
             ))

(dolist (func funcs)
  (import libcucul func))

(set 'consts '(
              ("BLACK" 0x00)
              ("WHITE" 0x0f)))

(dolist (const consts)
  (constant (sym (const 0)) (const 1)))

(context 'CACA)
(set 'libcaca "/usr/lib/libcaca.so")
(set 'funcs '(
             "caca_create_display"
             "caca_set_display_title"
             "caca_refresh_display"
             ))

(dolist (func funcs)
  (import libcaca func))



(context 'MAIN)

(set 'cv (CUCUL:cucul_create_canvas 0 0))
(set 'db (CACA:caca_create_display cv))
(CACA:caca_set_display_title db "Hello!")
(CUCUL:cucul_set_color_ansi cv CUCUL:BLACK CUCUL:WHITE)
(CUCUL:cucul_putstr cv 0 0  "This is a message")
(CACA:caca_refresh_display dp)
#6
newLISP in the real world / newlisp and libcaca
September 09, 2007, 05:02:25 PM
Hi all



I'm trying to get libcaca (an Ascii  basically just the basic tutorial that can be found at:



http://linux.die.net/man/3/tutorial">//http://linux.die.net/man/3/tutorial



However i get a segfault at the line " caca_refresh_display(dp);"



running an strace shows : gettimeofday({1189337045, 203711}, NULL) = 0



I've tried running the program with and without the refresh line (not having a refresh means that there is not so much of the output but there are no significant differences in the strace before the failure point.



Note I tried compiling the example in C and it works fine on its own. Anyone have any ideas on what to try next in debugging this, I'd really like to get libcaca working with newLisp.



regards



Konrad
#7
Anything else we might add? /
September 07, 2007, 03:46:08 PM
At the moment I have a Context with a paths symbol that evaluates to a list.

you are correct in that this symbol should be set based on the current platform.
#8
Anything else we might add? / Autoloading
September 07, 2007, 04:44:21 AM
One thing I have missed coming from python is the ability to have load find

modules for me, rather than having to know where they are on they are on the filesystem.



Writing somthing like this is easy. The question however is what should the searchpath be?



currently I'm using:





"."

"./modules"

"/home/USER/.newlisp/modules"

"/usr/local/share/newlisp/modules"

"/usr/share/newlisp/module"





is there any kind of general consensus on this. Along the same lines is there any sites which index and list the available newLisp modules, somthing along the lines of the kind of master repostories that Perl and Python have ?



PS the code I wrote is quite unix specific but I do plan to share it once I work out a good home for it, either google code or sourceforge would is likely at the moment.
#9
newLISP newS /
September 03, 2007, 06:36:50 PM
Quote(4) Integer and Float Arithmetik

You can redefine the integer operators (see manual) and then you get just the same number treatment you have in other scripting languages.


This is about the only critisism I would agree with. + - etc should be smarter. And by smarter I don't meen should return floats at is as dump as always casting to an integer. Having spend a long time in Python probably gives me some Bias. but havign arithmatic operators which do things in Integer mode if you give them integers and in float mode if you give them floats seems to be the best alerantive.



In Python (yes I'm comparing languages) Ints and cast to floats implicitly If and Only if there they are being combined with somthing which already is a float. so that



1+1 = 2



1+ 1.5 = 1.0 + 1.5 = 2.5



Granted doing this efficiently could be non-trivial. but I would on balance rather it be the general case and have a set of explicitly Integer variants for cases where I know I really want Integer operations.



iadd etc perhaps.
#10
Anything else we might add? /
August 26, 2007, 05:11:13 AM
Look foward to reading your summary,



regards



Konrad.
#11
Anything else we might add? / newLisp Internals
August 23, 2007, 08:12:05 PM
Hi I was just wondering if there was any documentation (other than reading the source) on how the newLisp interpreter actually works and what data structures it uses to do its job?



About the only thing I seem to have been able to find is the paper on Memory Management.