lispnik / iup

Common Lisp CFFI bindings to the IUP Portable User Interface library (pre-ALPHA)
Other
139 stars 7 forks source link

README update #47

Closed defunkydrummer closed 5 years ago

defunkydrummer commented 5 years ago

Updated Readme with more complete instructions on how to install and load IUP.

This solves the issue i submitted about IUP being difficult to load and install.

cmatzenbach commented 5 years ago

This really needs to be merged. I'm a contributor to IUP (working on a WebAssembly backend for the library) and have been wanting to learn CL, so I saw this library and was suiper excited to try it out and work on my lisp skills. It took me over 4 hours to get this installed until I managed to find this commit. It is impossible to install without these additions. Yes, I probably should've realized what was going on, but considering the work is already done and sitting right here, and considering the great work done on these bindings, I think it's imperative that this gets merged for any future users that end up in my situation.

lispnik commented 5 years ago

Sorry, I was kind of awol. Thanks for reminding me to merge this.

lispnik commented 5 years ago

@cmatzenbach thanks for trying it out and having the patience. I'd be interested in any other new-to-CL experiences you have with this library.

cmatzenbach commented 5 years ago

@lispnik Sure thing! It actually goes both ways :grin: , I'm curious how you implemented some of these widgets and want to play around and checkout relative source code. I also hope this won't be too difficult a task given that I'm a complete beginner at CL, besides working through about 1/3 of PCL.

I'm so glad you took the time to write all this though, thank you SO MUCH for your time and effort. From writing an IUP backend myself I know it is no quick task. And over a year ago when I first got initial interest in CL I wanted to do an IUP program in it, but soon learned the only cl-bindings were truly horrible. I was in shock when I randomly googled it again after 1.5 years and saw your two repos pop up as the first results - and they were recent too! I was floored, not only that others still use IUP, but that there are poeple out there wiling to take thier time to write a bacckend for a great native GUI library in a fantastic (albeit niche) language. Much, much kudos to you man, thanks for giving this to the community, this is truly awesome and is what makes open source great.

cmatzenbach commented 5 years ago

@lispnik Ah. here's one initial comment I have. In both libraries you say they are on quicklisp, yet neither was there (well I can confirm that "tecgraf-libs" is not, tried numerous times as well as some folks from #lisp), I didn't try "iup" (just cloned in quicklisp/local-packages/ like with tecgraf-libs and then run (ql:quickload "iup") like I also did with "tecgraf-librs", which both installed fine after that). But both READMEs heavily suggest they are on quiklisp which is no longer the case, so I think some instructions on cloning locally in the correct folder and then running quicklisp would be helpful to new users. If you don't have time let me know and I could write that up for you and submit a PR.

I'm also a tad confused if I should add "cffi" to my .sbclrc so it always starts up when sbcl runs, or if that is unnecessary and there is another way I should be doing it instead. I've read through each README a couple times but never could figure that out, but that could just be my shitty reading comprehension :laughing:

lispnik commented 5 years ago

@cmatzenbach Sure regarding the construction of the bindings: My main goals were: "lispiness", completeness and low maintenance. So there are actually two aspects to the bindings. There's a iup-classesdb system and then there are all the other iup-related systems: iup-{cd,controls,gl,gl-controls,im,imglib,mglplot,olecontrol,plot,scintilla,tuio,web}.

The iup-classesdb system is designed keeping up to date with IUP library version changes.

What is basically does it call the IupGetAllClasses for each iup module (cd, controls, etc.) and iterates over them calling IupGetClassAttributes and IupGetClassCallbacks and builds a DB (actually just that classesdb.lisp-sexpr you see in the repo https://raw.githubusercontent.com/lispnik/iup/master/classesdb.lisp-sexp After doing that, you don't need the load the iup-classesdb anymore (unless you're the maintainer and want to regenerate the file when a new version of IUP comes out upstream).

classesdb.lisp-sexpr is the Lispy definition of all the IUP modules. When you load for example, the base system, iup.asd, it reads that file at compile time and creates all the Lisp functions. The functions it creates include nice argument completion and documentation, defaults indications, names that are fairly consistent with the IUP docs themselves (there's actually a vanity-classname key in there where I use to change some namings), attribute handling (and auto-conversion from Lisp objects to IUP strings, in most cases) and most importantly the callback handling so you can pass around Lisp functions and symbols instead of pointers to C callbacks. The callback wrapping includes a handler for returning IUP_DEFAULT in the case of an error so you don't crash your Lisp.

It works pretty well. It's also one of those things that would not have been easily accomplished without access to the Lisp system at compilation time, ie. macros :-) Actually, when you're translating a C program for IUP into Lisp, you can often find places where the C author is setting an attribute that is actually invalid for the IUP class they're trying to use!

I did include a bit on all of this in the README a while back, but it was geared more towards experienced Lisp users. I'll try and take this github comment and combine it into the docs for everyone.