freenode/#lisp - IRC Chatlog
Search
10:31:26
schweers
Given a class, I want to get all slots in it (to generate some code for every slot). Do I have to use MOP for this?
10:33:20
no-defun-allowed
You could write a macro which reads the defclass slot descriptions and generates code from them.
10:33:21
schweers
Now that I think about it, I could instead use a macro which defines both the class and the code per slot. This may be easier.
10:41:19
beach
schweers: Using the MOP is usually not a problem. There is the CLOSER-MOP library for that.
10:42:42
no-defun-allowed
Maybe https://stackoverflow.com/questions/40742048/is-there-a-way-to-get-the-slots-of-a-class is relevant for this use case.
10:44:14
no-defun-allowed
The stackoverflow post provides code to get slot names though, through slot-definition-name.
10:46:44
schweers
I’ll just create the class and the assorted per-slot code in a single macro. It also saves some work in defining the class.
10:48:41
schweers
But I’ll have to look at MOP someday. It’s a shame that I’m limiting my designs by not knowing MOP.
10:58:25
schweers
My guess is also that it will understand my CLOS and general OO understanding. So that alone is probably a good reason to learn more about MOP.
13:15:32
dim
beach: hi! I stumbled upon http://herpolhode.com/rob/utah2000.ps this morning and got to think about your LispOS project in that context again, so I though if you didn't read the piece from Rob Pike before, you might like it... the title is “Systems Software Research is Irrelevant” and it was publised Feb 21, 2000
13:34:11
heisig
If I remember correctly, Rob Pike once convinced Stephen Wolfram to write Mathematica in C instead of Lisp. His argument was that 'C is more modern'.
13:34:32
heisig
And the fun twist - Pike is now working on Go, which is basically C with GC and closures.
13:40:39
beach
My thesis advisor tried to convince Wolfram to use our very efficient rewrite engine as the core of Mathematica, but he declined.
13:43:52
heisig
The interesting part is how even very smart people like Wolfram can make software engineering decisions that are totally bonkers.
13:50:16
beach
And this is my dissertation, but no PDF is available: https://dl.acm.org/citation.cfm?id=59707
13:52:05
beach
My dissertation works is summarized here https://link.springer.com/chapter/10.1007%2F3-540-51081-8_125
13:52:47
beach
I have vague plans to typeset my dissertation using LaTeX, but I am too lazy I think.
13:55:42
lieven
Guy Steele convinced Knuth his typesetting system needed to be programmable. And then Knuth chose a macro rewriting system :(
13:57:14
beach
The book by O'Donnell describes the language and an interpreter for it. I generalized the class of programs that could be handled, and I showed how to write a compiler for it, rather than an interpreter. The compiler uses partial evaluation in an interesting way, in that part of the compiled code is generated from partial evaluation of the same code that is compiled.
13:58:46
shka__
beach: would same approach be usefull for creating lisp-embedded efficient logic programming language?
13:59:38
shka__
by that i mean something around the same order of magnitude fast as prolog implementations
13:59:54
beach
Yes, but not Prolog-style "logic programming". Equational logic programming, which is basically rewriting.
14:01:08
beach
But, yes, I have had plans to embed the engine in Common Lisp. The compiler that I wrote for my dissertation generated VAX assembly code.
14:02:16
lieven
ACTION started in between the 'all the world is a vax' and 'all the world is a sun' periods
14:05:11
shka__
authors even implemented basic prolog-like language in it using java, codebase was very compact and performance was more then decent
14:05:18
Ukari
the code `(funcall (lambda () (print "foo")) "bar")` will throw a `invalid number of arguments: 1` error, I know use `(lambda (&optional x))` could prevent from it, but is there anything equivalent to the `funcall` but which could auto decide between expression-A `(funcall (lambda (x) (print "foo")) "bar")` and expression-B `(funcall (lambda () (print "foo")))`, and not rely on a specific implementation?
14:06:10
Bike
Ukari: there's no function that will tell you how many arguments a function accepts, if that's what you mean.
21:24:51
moldybits
ah, setting *print-radix* to t gets me a #b prefix. that's nice. i presume the pretty printer will allow me to get something like 5 => 5 (#b101)
21:26:27
jasom
moldybits: yes you could install a pretty print dispatch entry for type rational (or maybe integer) to do that
21:26:55
specbot
Pretty Print Dispatch Tables: http://www.lispworks.com/reference/HyperSpec/Body/22_bad.htm
21:56:09
moldybits
hm, slime keeps crashing for when i try to set-pprint-dispatch 'integer to whatever, while 'float works fine.
21:58:35
moldybits
*print-base* and *print-radix* will have to do for now. thanks, jasom and LdBeth!
22:03:40
moldybits
does this seem like a reasonable thing to do? (take-bits 3 #b10101111) => #b101 and (discard-bits 3 #b10101111) => #b1111
22:05:42
emaczen
Do we have to use eval-when for reader macros in a file? Or is there a way to make it implicit?
22:10:20
jasom
something like: (defun take-bits (n x &optional (byte-size *byte-size)) (ldb (byte (- byte-size n) 0) x))
22:13:13
jasom
with typo correction, seems to work: (defun take-bits (n x &optional (byte-size *byte-size*)) (ldb (byte (- byte-size n) 0) x))