freenode/#lisp - IRC Chatlog
Search
14:08:20
dim
I didn't follow closely and am wondering if ABCL is relevant to this Java/Common-Lisp discussion
14:16:54
xificurC
can someone enlighten me how to correctly generate unhygienic code here? http://ix.io/2M0v . `aif` is just an example
14:17:07
heisig
We recently had a project where we needed a computer algebra system in Scala. Our solution was to load ABCL into the same image, and to use ABCL to load Maxima.
14:19:21
heisig
xificurC: Your code is unhygenic, but you are in the wrong package. You pollute c::it, but write a cl-user::it.
14:20:33
xificurC
heisig being unhygienic is the point in this case :) The fragment generates `C::IT` but I want to generate `IT` for whatever package is using the macro. Does that make sense?
14:21:00
beach
xificurC: Symbol names are handled at read time. At macro-expansion time it's too late.
14:21:25
heisig
xificurC: Be careful what you wish for :) I would suggest having the package C export IT, and to have other packages import it.
14:21:45
heisig
But if you really want to capture all kinds of IT, you need a substituting code walker.
14:22:19
xificurC
I don't remember Paul Graham talking about this stuff in On Lisp. Was he just avoiding this whole topic by not using any packages?
14:22:29
beach
xificurC: Also AIF is really strange, since it handles general values as if they were Booleans. You are much better off without it.
14:22:49
Xach
xificurC: paul graham did not document all the features of common lisp. packages are not discussed in detail.
14:23:32
heisig
xificurC: If you really want to try this, use a code walker like https://gitlab.common-lisp.net/mraskin/agnostic-lizard and have AIF replace all symbols named IT with C::IT.
14:24:05
xificurC
so let me rephrase to see if I understood this: to use unhygienic macros across packages one would need to use a code walker
14:25:33
beach
xificurC: In fact, most of the anaphoric macros are weird and should probably be avoided altogether.
14:26:30
beach
It's a cute exercise in how the macro system can be used, but not particularly useful, and not particularly conform with other software-engineering practices.
14:28:14
heisig
xificurC: Here is one more solution: Your AIF macro could intern the name "IT" into the value of *package* that is used at macroexpansion time. But that would also violate some assumptions that readers of your code might have.
14:34:47
xificurC
as I said `aif` wasn't the particular example. This one was http://ix.io/2M0x . It's similar to what is in LOL but closer to a clojure-like anonymous function definition. I find the shortcut useful and code written with it clearer. However it doesn't work across package boundaries, just like any unhygienic code doesn't seem to
14:37:32
xificurC
looking into the LOL codebase I see the same issues, the unhygienic symbols `a1` `a2` etc don't solve this issue. I wonder why are these books given such high praise then, when you take some code from it and use it in a standard way, failing immediately
14:40:12
beach
xificurC: On Lisp is good for things like computations done at macro-expansion time, but not for anaphoric macros.
14:51:41
xificurC
mfiano the book went really hardcore into some custom closure-based OO design and I didn't really understand why would one want to do that instead of using CLOS. The macros were interesting and the sorting networks too
14:53:07
_death
xificurC: I would advise not using such macros in CL.. but in your particular, the issue likely stems from interning symbols in the current package where the reader macro is expanded (which is likely what you want) but the expansion refers to symbol (% %1) interned when the reader macro is defined.. so you should use the ones you interned instead
14:55:12
frodef
maybe for very application-specific things, where words have very particular meanings.
14:57:39
heisig
ACTION sees Clouseau's representation of complex numbers and goes on to rebind `C-c i'.
14:58:17
xificurC
I guess the number of APL fans here is very close to 0. Anything that allows expressing yourself more concisely is worth consideration
15:03:13
mfiano
It's mostly a book about "Hey, look at what macros can do", but the very opinionated coding style that ignores conventions and the use of anaphors make it very rare you will ever see code like this in the real world.
15:07:16
xificurC
like this? https://github.com/thephoeron/let-over-lambda/blob/master/let-over-lambda.lisp :)
15:11:54
aeth
xificurC: Lexical closures are the only true way of doing encapsulation that's not just by convention (I say this, but now someone might think of something more obscure). Lexical scope is so encapsulated that lexical variables might not actually exist for things like debuggers without (optimize (debug 3))
15:12:16
aeth
xificurC: So you could probably come up with a very niche situation where you need to do that. Very niche.
15:15:51
xificurC
aeth I actually loathe enforced encapsulation that cannot be broken. In the few years I work on the JVM there have been several bugs in 3rd party libraries that I was close to unable to overcome because of it. I think we're all adults and know the risk of using internal, subject-to-change parts of a library.
15:20:50
heisig
shka_: I am still experimenting. I will post my solution here as soon as it is presentable.
15:28:07
scymtym
heisig: one piece of the puzzle will probably involve updating the content of a persistent inspector window. one way to do that is (defvar *inspector* (nth-value 1 (clouseau:inspect INITIAL-VALUE :new-process t))) and later (setf (clouseau:root-object *inspector* :run-hook-p t) NEW-VALUE)
16:17:09
heisig
shka_: Here is my first draft: https://gist.github.com/marcoheisig/ddf35ad94e51fe9c3e5980759ef0fb70
16:22:22
heisig
scymtym: Yes, there are plenty of potential tweaks. Also, I should overload more than just `C-c i'. But that was already enough of a digression for one day.
16:24:51
heisig
Also, I am not exactly proud of referencing a symbol from clim-internals. Is there a better way to check whether a frame is still alive?
16:51:57
scymtym
heisig: maybe http://bauhh.dyndns.org:8000/clim-spec/28-5.html#_1560 ? the states are defined at the top of the page
17:11:22
adlai
Oh boy, here I go bearing bad news again! ... if anyone both industrious and stupid wants to volunteer to maintain yet another library slipping towards gitrot, it appears that Anaphora has been soft-abandoned.
17:12:00
adlai
[ as hinted by the maintainer, at https://github.com/tokenrove/anaphora/pull/10#issuecomment-757917329 ]
17:13:41
adlai
ACTION has anaphoric macros all over scalpl, even occasionally wrote a few of his own, although already has the volunteer hands more than full with wondering wtf to do about chanl's brokenness, an issue that blocks returning scalpl to official inclusion in various automated distributions.
17:16:37
adlai
while we're on bad news of abandonment: Henry Baker's paper archive has gone offline, apparently along with the entire webserver that hosted it. Wikipedia is already linking to https://web.archive.org/web/20200212080133/http://home.pipeline.com/~hbaker1/ although I do wonder whether anyone has available an archive of just the signal, to save others the trouble of sifting through HTML noise.
17:31:52
jackdaniel
you know what would be cool? displacing (unsigned-byte 8) array to (unsigned-byte 32) so first four elements in the former go through the first element in the latter
17:36:24
aeth
Another thing CL is missing that implementations could add is optimized heterogeneous 2D/3D/etc arrays.
17:37:03
aeth
so e.g. an array where every row looks like: single-float (unsigned-byte 8) double-float (unsigned-byte 32)
17:37:50
aeth
If it could reasonably be done as an extension, it would be compatible with portable CL since it'd just be a regular T array for those other implementations
17:38:59
jackdaniel
I'm rewriting McCLIM clx renderer to always use xrender extension: https://i.imgur.com/3Kb4gmH.png ; that's why I've asked (I can't simply "cast" array even when I know that bytes are in correct order)
17:41:44
adlai
however, provided that the array is an unboxed array of structs with unboxed immediates, that could have quite low overhead, if you have lots of state per cell.
17:41:48
aeth
adlai: you can get close if you put a bunch of different homogeneous arrays inside of a struct
17:42:57
aeth
adlai: you can't have an element type of a struct, that's just going to be T, and semantically speaking, it's not going to work to have an array of a mutable element like a struct work in a specialized way.
17:43:31
aeth
Whereas what I described would basically be like structs if you wrote the right kind of accessors, but without the semantic problems, although it would kind of mess with the concept of initial-element
17:45:48
aeth
An array row of (single-float (unsigned-byte 8) double-float (unsigned-byte 32)) is an array row of things that can all be an upgraded-array-element-type in arrays in reasonable implementations, just not all in the same array at the same time.
17:46:12
adlai
well, if all your immediates are numeric, you can probably fake it quite closely with jackdaniel's trick and possibly a bit of ldb and decode-float gluearbage.
17:47:24
adlai
ACTION leaves off pursuing this optimization, however mature it may be... enjoy your bit-twiddling!
17:47:45
aeth
Well, several problems there. First, arrays can store more than fixnums. An implementation could reasonably store unboxed double-float (larger than a fixnum), (unsigned-byte 64), or (signed-byte 64) in 64-bit implementations.
17:48:09
aeth
In fact, if you're working with such numbers, you're probably better off overusing mutable arrays to avoid boxing
17:48:59
aeth
Second, this would be for very high-performance things, so converting an integer to a float each time might have a cost. Even a tiny cost can add up. I had a 3D renderer in mind when I was thinking about this.
17:50:00
jackdaniel
I feel like in this meme with a pigeon (https://knowyourmeme.com/memes/annoyed-bird), laters \o
17:50:29
adlai
that would be the correct function, not decode-float, since the latter doesn't actually rescue you from the floatsam!
19:02:37
jackdaniel
looking at ecl code it seems pretty much doable - i.e by relaxing the displace requirement to allow an array with a /compatible/ element type
19:03:27
jackdaniel
there is also a cute internal function: (si:array-raw-data array) that returns an array with the element type byte8 (works on all arrays with the specialized element type)