freenode/#lisp - IRC Chatlog
Search
14:56:39
gypsydave5
I was having a conversation with a friend about CL - they're pretty in to Go - and he was wondering how to write a CL program that compiled to a binary. I had a go with ECL, which worked - but required a the ECL dylib to be on the libraries path. Does anyone know if there's a way to compile ECL which would produce a (mostly) portable binary in the way that Go does?
14:58:22
beach
gypsydave5: You would have to ask jackdaniel. But other implementations can certainly produce "standalone" binaries, like SBCL. They get pretty big though, because they must include the entire Common Lisp run-time system.
15:00:49
gypsydave5
beach: Yeah, I did it for SBCL, and using Roswell, which was nice and easy. I was _kinda_ trying to compete/show off with the binary size. The 'hello world' from ECL was comparible with the size of a C binary.
15:01:41
beach
gypsydave5: You can't do that basically. The Common Lisp run-time contains the entire compiler and the garbage collector.
15:02:01
gypsydave5
pjb: Hmmm... I'm ignorant about what's happening under the hood in Go. So maybe it's comparing apples to oranges.
15:03:34
pjb
gypsydave5: (actually ldd, and otool -L only gives the minimal set of shared libraries. The program can also dynamically load other libraries at run-time).
15:05:26
pjb
The small sizes of memories in our childhood computers has been a big trauma for all of us…
15:08:30
pjb
or clicc for a free software equivalent (but clicc would require some love and updating).
15:10:12
gypsydave5
yeah... just looked at the dependencies from otool on the ECL hello world and there were another three libraries it needed.
15:12:29
pjb
gypsydave5: shared libraries are good. Often programs will depend on 50 or hundreds of shared libraries. This is what makes the size of the binaries small.
15:38:43
phoe
in that way, you could treat the SBCL binary as a runtime (and therefore provided by system, doesn't count into your executable size!) and only take into account the FASL size
15:40:52
phoe
which is essentially what happens with all interpreted languages whenever you launch stuff like ./python_file.py from the shell
15:41:34
phoe
so you could theoretically compile a (format t "Hello world!~%") into a FASL and run that.
15:43:17
oni-on-ion
yea =) i just guess that slime/swank compiles a bunch. i thought that sbcl had some of its own in ~/.sbcl/ but i dont have that. are they bytecode+native ?
15:44:02
phoe
it's basically a dump of Lisp data, straight from memory - plus some data to make it loadable
15:46:43
phoe
they're volatile though - you need to use the same architecture, the same implementation and the same implementation version.
15:47:11
phoe
you can't execute Windows fasls on Linux, SBCL fasls on CCL, SBCL 1.4.9 fasls on SBCL 1.4.10.
15:49:50
phoe
theoretically you could use some Lisp debugger to inspect that, since it's all just Lisp data, but in practice, it ain't trivial.
16:24:15
PuercoPop
phoe: what are your use cases? For running shell scripts I use cl-launch (mainly to launch StumpWM and used it to try out lem)
16:27:41
PuercoPop
^_^, I just compile from source. I've been meaning to give guix a try though. I'm surprised it has SBCL, SLY, StumpWM, etc as readily available packages
16:28:59
phoe
and we can't make them identify because both nicks are taken, and #common-lisp.net doesn't know the passwords.
16:35:53
oni-on-ion
most of my channels need registration, but i cant talk to nickserv without a channel joined associated with the server, so then i can join everything by hand after identifying manually. this is the reason i dont shut off my desktop as often as i'd like
16:56:48
beach
... to evaluate in order to get the core-file-name that save-lisp-and-die wants as its first argument.
18:14:53
slyrus1
phoe: there's a new version for you with 16-bit support and properly exported symbols. Let me know if you need anything else!
18:15:17
slyrus1
it's still on the branch on all 3 repos. If you can give it a review, I'll merge to the master branches.
19:32:36
phoe
; Call to FOO:BAR could not be inlined because its source code was not saved. A global INLINE or SB-EXT:MAYBE-INLINE proclamation must be in effect to save function definitions for inlining.
19:32:42
|3b|
in particular, you should declaim the global function inline before defining it to tell implementations you would like them to save data for inlining
19:33:01
|3b|
and then declaim it notinline after defining it for the local declaration to not be redundant
19:35:01
|3b|
like defining the package manually to declaim it before loading, or putting something on *macroexpand-hook* to do so during the DEFUN, neither really suitable for released code :)
20:20:12
flip214
anyone to help with cl-sat? SAT:SOLVE throws an error "the value NIL is not of type NUMBER" in PRINT-CNF
20:35:00
kristof
So... I had been planning on offloading macro-expansions (and especially read-time expansions!) of a common lisp source file to sbcl or some other expansion but
20:36:10
kristof
I had forgotten that most facilities in lisp are defined as macros which expand into internal implementations, such as sb-impl::%defun
20:37:27
pjb
kristof: all CL implementations are suitably minimal lisp implementations built over macros.
20:39:43
aeth
kristof: do you mean something like repeatedly doing macroexpand-1 until you stop getting portable forms?
20:40:30
kristof
And I don't even want a minimal one, either. For instance, I'd want defun to be a special form, not a top-level set-fdefinition...
20:40:43
pjb
kristof: there are 35 special operators (not all of them are semantically significant), about 70 macros (they can all be written with a conforming expansion), about 30 reader macros, and plenty of functions, of which only a few are "primitive" for some meaning of the term (for example, APPLY).
20:41:06
pjb
kristof: so you can implement a CL by implementing only those special operator and a few functions.
20:41:16
kristof
pjb: The special forms are not the issues, actually. In fact, now that I think about it more, what I don't want is a small lisp, what I want is one that's larger than what they usually expand to
20:41:38
aeth
kristof: Then I guess the way I'd do it is I'd repeatedly macroexpand-1 until I get to a desired form (i.e. part of a MEMBER type that I defined based on the HyperSpec).
20:42:59
aeth
There's also e.g. (macroexpand-1 `(dotimes (i 42))) ; in SBCL it's built on DO, in some implementations I think it uses an internal macro or its own TAGBODY
20:43:16
kristof
I see now that I can't have my cake and eat it, too. Basically, I don't want to write a lisp to handle macroexpansion, existing lisps are plenty good. But I also wanted to suppress the macroexpansion of certain commonplace forms like defun, because that high level information is useful to me.
20:44:11
kristof
I would hope to use sicl eventually. I just wanted to do my own thing for a while, for instructive purposes. I have not heard of sacla.
20:46:09
|3b|
you could try expanding the macros yourself using implementation macroexpander where it works and your own if needed
20:46:31
|3b|
so you write a code walker but hopefully can reuse some of the implementation's macros
20:46:31
aeth
kristof: I think you want something like this: (let ((candidate-macroexpand (macroexpand-1 foo))) (if (typep (car candidate-macroexpand) member-type-with-forms-to-stop-on) #| continue on the candiate-macroexpand |# #| return the old macroexpand |#))
20:47:18
PuercoPop
kristof: maybe CMUCL/SBCL's IR1 would work for what you want? The CMUCL design document describes as a subset of CL
20:47:22
|3b|
or just read things into a package that shadows things like DEFUN where you don't like the built-in definition
20:47:23
aeth
kristof: e.g. (macroexpand-1 `(dotimes (i 42))) in SBCL gives a form beginning with DO and (macroexpand-1 (macroexpand-1 `(dotimes (i 42)))) gives a form beginning with BLOCK over a LET over a TAGBODY
20:48:03
kristof
Although I also like |3b|'s idea, to be honest. I could write my own package that doesn't use CL and imports only the macroexpansions I want.
20:49:19
kristof
PuercoPop: if I'm going to eventually port to Cleavir I see no reason to devote myself to someone else's IR, but I appreciate the suggestion
20:51:26
pjb
kristof: if you want more "primitive" then go ahead! ALL the operators in CL can be primitives! The macros in CL can be special operators (but you must still provide macros for the user programs to macroexpand them), and all the functions in CL can be open-coded.
20:57:27
aeth
kristof: (defun macroexpand-until-symbols (form) (loop :for macroexpand := (macroexpand-1 form) :then candidate-macroexpand :for candidate-macroexpand := macroexpand :then (macroexpand-1 macroexpand) :until (or (typep (car candidate-macroexpand) '(member do)) (eql candidate-macroexpand macroexpand)) :finally (return macroexpand)))
20:57:51
aeth
That stops macroexpand-1 on either DO or exhausting the macroexpansion (i.e. the macroexpand being itself)
20:59:42
aeth
hmm, doesn't work on (defmacro foo (i &body body) `(dotimes (,i 42) ,@body)) (macroexpand-until-symbols '(foo a))
21:01:49
aeth
This one works on both: (defun macroexpand-until-symbols (form) (loop :for macroexpand := form :then candidate-macroexpand :for candidate-macroexpand := (macroexpand-1 macroexpand) :until (or (typep (car candidate-macroexpand) '(member do)) (eql candidate-macroexpand macroexpand)) :finally (return candidate-macroexpand)))
21:03:22
aeth
You have to have two versions of the macroexpand to eventually terminate in the case that it's not part of the member type, in this case an example would be '(defun foo ())
21:10:16
pjb
Or you can macroexpand in an environment where you've removed all the macros that are implemented as special operators.
0:51:16
pjb
You can alway (defun fpos (f) (file-position f)) (defun (setf fpos) (n f) (file-position f n) n) and use fpos instead.
0:54:12
|3b|
but silently discarding errors doesn't seem good either, so i'd say it just shouldn't return if it can't validly return the value returned from FILE-POSITION
0:54:59
pjb
I've got a serie of accessor to read and write files, but of course, you have to take them with a grain of salt.
0:55:23
|3b|
ACTION can't tell from spec if it is allowed to set it to a position other than the one you requested (and then return that different position, though doesn't seem like it)
0:56:05
pjb
The only file position that have a good chance of success are those returned by file-position.
0:57:33
pjb
So, you have (unsigned-byte 8) files, which will probably do what you expect on posix systems, and there are other files for which you need to be more careful.
1:10:43
AeroNotix
pjb: thanks for informing me that functions and setf functions are a possibility in Common Lisp