libera/#commonlisp - IRC Chatlog
Search
18:12:15
Bike
yeah, if you want to be able to interleave frames from both languages C++ pretty much forces you to play by its rules
18:12:41
Bike
the itanium exception ABI everyone uses nominally works with different languages, even ones with different models, but it's a lie
18:16:59
jcowan
Well, it probably works with everything except Lisp (broadly considered, including Dylan)
18:19:14
Bike
i'm not sure about that. non-C++ exceptions are kind of second class citizens. doing stuff like trying to rethrow them from a handler can cause the C++ runtime to give up and terminate
18:21:17
Bike
http://ix.io/3yRX i wrote a quick gloss of what implementing return-from with exceptions looks like. it's not great
18:21:48
Bike
c++ won't let you write return-or-control-error, since if throw doesn't find a handler it terminates
18:26:13
Bike
i think windows SEH is a little less dumb? at least it has finally blocks, which are sort of annoying to emulate
18:32:13
Bike
although i recall some complaints that the details of continuations within dynamic-wind are ambiguous
18:53:45
jcowan
In addition, there is a mysterious discrepancy between Scheme and CL exception handlers: a Scheme handler exits when the exception is handled, and reraises when it needs to pass the buck.
18:55:05
Bike
oh, you mean like if the handler function just returns further handlers aren't called?
18:56:16
jcowan
Right, and what the handler returns is what raise-continuably gets. If you call raise instead, it will immediately raise another exception.
18:57:22
jcowan
So it's more like Java etc., although it does not rewind the stack unless an explicit non-local jump is done (which is implicit with guard, the analog of handler-case)
19:23:42
copec
(Forgive the hopeful/ignorant questions) Bike: Could clasp be bootstrapped all under the wasm? Do the C++ exception semantics get mapped to Wasm, so that the work you've done in clasp would carry?
19:30:06
Bike
c++ exceptions are basically slow by design (as they are in practice implemented), so, yeah
19:31:24
shka
Bike: maybe you are bored and want to explain how c++ exceptions implementation is different from exceptions in lisp?
19:33:16
Bike
lisp implementations usually cons a bit on the stack to indicate the presence of exit points and cleanup blocks to the unwinder
19:34:00
Bike
C++ implementations instead record information about exit points and cleanup blocks in the executable file
19:35:00
Bike
the good part of that is that it means no consing whatsoever. the bad part is that getting that information becomes orders of magnitude slower
19:35:35
Bike
it's "zero-cost exception handling", yeah. i don't know if that's conceived relative to C or anything
19:36:28
shka
iirc the running gag in C++ community is that C++ exceptions are 0 cost, unless you actually want to use it
19:36:46
White_Flame
I always balk at that description. The handling is very expensive. It's when exceptions aren't fired/handled that it's zero cost
19:38:27
Bike
it even screws up parallelism, since the unwinder might have to walk loaded shared objects to find the code, and that's lock protected
19:39:47
Bike
or "throw less exceptions", which is pretty much what we're doing, because we can't make C++ faster
19:40:00
jcowan
Given that most actual problems in C++ code don't throw exceptions but are just UB, there is a point to that.
19:40:27
Bike
we have it set up to use setjmp/longjmp instead which we can, which works much faster, but probably isn't supported by wasm
19:41:14
White_Flame
every C++ project always has an exact subset of the language that they agree to use
19:41:17
jcowan
Also, it is false that exceptions are zero-cost, because every one of them bloats your code, which squeezes more out of cache
19:41:47
White_Flame
It's almost architecturally impossible to actually use all of C++ in one codebase
19:43:20
Bike
jcowan: yeah, that's true. we haven't really noticed since we do actually use exceptions and that's so much worse :/
19:43:59
shka
C++ with all the templates stuff can become really, really, really good example of code bloat anyway
19:44:42
lotuseater
or not just shooting easily in the foot like with C but instead rip of the whole leg at once
19:55:59
copec
Bike: It seems like it would have almost been easier to make a binary translator for Dr Meister to suck his C++ libraries into a CL image rather then to suck CL into C++
19:58:25
copec
I come from an aspect of someone who has used dtrace fairly often and has the debug symbols
19:59:17
copec
and then I see stuff like high level emulation binary translation for video games, and wonder if you could parse and translate a binary library into a usable lisp library
20:00:25
shka
but the thing is, C++ libraries currently in use really need that code generation templates offer
20:02:49
Bike
so they work normally with slot-value and stuff, but you can also sling them at C++ functions expecting the superclass
20:07:30
Bike
how do i feel about it? well, i'm hoping to soup up the compiler, mainly. nothing directly c++ related
20:09:53
yitzi
As a user of clasp the performance has improved dramatically over the last year and half. But as Bike said there are certain things you have to be careful about like signals.
20:12:19
copec
I'd love to see clasp tied into unreal engine for all sorts of direct parametric generation fun
20:18:50
yitzi
drmeister uses ngl via ngl-clj generally for 3d. ngl-clj is a lisp widget for ngl (3d molecules) that I wrote for juyter lab.
21:16:30
jcowan
One reason langs with a C FFI rarely have a C++ FFI are header-only libs (there are many others, from overloading to exceptions themselves
22:26:48
lotuseater
mfiano: So kind of itself younger sibling "No, I don't want to play with them!" :D
0:21:08
moon-child
jcowan: as far as I know, the only languages that interface directly with c++ without compiling to it are d and raku. Are there any other notable ones?
1:29:36
ln43
Hi all, i'm using Portacle on windows and quicklisp to load closer-mop but it does not seems to work since when i do closer-mop: and press tab there are not completions for the symbols exprted by that pachage
1:31:46
ln43
and to be sure i tryied to replicate the example in clcookbook (https://lispcookbook.github.io/cl-cookbook/clos.html) but whitout success using that system
1:32:11
ln43
so ... i would like to use it in order to install sicl and without maybe i can't procede further
1:37:53
ln43
is there a way to remove closrer-mop with quicklisp and then try to reinstall it (maybe from github)?
1:39:05
ln43
really i can't figure out how to proceed and a possible way to solve the issue: closer-mop in my case seems that doesn't works ...
1:42:44
ln43
yes i'm trying to reboot again sicl but the issue is that a symbol that should be required and it's defined inside that package is not available during the sicl boot
1:50:27
ln43
anyway yes moon-child, i will try to delete the actual package and reinstall it but after inspection of the package's folder everythong seems ok... do you know if there is any other way to have closer-mop working ?
2:27:13
Guest92
so (april:april-load ...) is a compile-time macro, I inserted it within a let block, but it is not evaluated when I call the function which houses the let block
2:30:19
White_Flame
in that case, the macro might be calling some other utility function which actually does the work. you should see if you could call that function instead
2:31:02
White_Flame
it's very handy for loader tools to work at compile-time, to capture any compilation errors right away as opposed to waiting for runtime, which is why it's written that way
2:32:42
Guest92
I have to modify my apl file, switch to the lisp buffer, compile, switch to slime buffer, test the function
2:39:14
saturn2
lotuseater: well, the author(s) of april could use eval-when to make it work the way Guest92 expected
2:39:49
Guest92
phantomics loads. Nested array model? or flat array model? or based array model? or...
2:41:29
moon-child
(my own implementation also uses that array model, which I didn't realise until I compared it to dyalog and dzaima and got strange results. I was somewhat gratified to find april behaved the same way!)
2:41:45
phantomics
However, you could have something that operates on lists if you pass the lists within an array and then use the :store-fn option to store a function within April that works on lists
2:42:31
phantomics
moon-child: in what places have you found April's arrays behaving differently from Dyalog?
2:43:50
phantomics
The underlying model is different but the behavior should be similar, since I automatically do some types of postprocessing to emulate Dyalog's behavior
2:44:08
mfiano
Where is AMOP's #'class-direct-methods defined? I don't see it defined in the book or in closer-mop.
2:44:15
phantomics
Guest92: you should be able to pass the same (with ...) parameters to (april-load) that you do to (april)
2:44:30
moon-child
hmm, that might be it. Perhaps I was using an older version? I seem to recall that ⍴0⌷(1 2)3 was ⍬ in dyalog, but ,2 in april
2:46:53
lotuseater
phantomics: I was curious how you are the last days since we queried recently, so good you're back. :)
2:47:00
moon-child
~inconsistencies. Personally, I find the 'nested' approach less consistent. Especially for things like /
2:47:33
phantomics
Been busy with work and getting some last to-dos checked before a new April release
2:47:53
moon-child
(indeed, sometimes I think boxes may actually be ideal. If it was good enough for sharp...)
2:50:16
phantomics
Guest92: The only docs for it now are here: https://github.com/phantomics/april#unique-language-features-in-april
2:51:20
phantomics
Maybe, or I may just try writing a BQN compiler since first-class functions are native to that lang and I could port all the April function impls over
2:52:28
phantomics
Scoping is the same as in Dyalog, when you assign a var inside a defn it's lexically scoped but you can do for example x←⊢1 to modify a variable outside a defn
2:54:23
Guest92
phantomics I guess what I meant by lexical scoping, are full clojures supported, because they are not in dyalgo
2:55:49
phantomics
You can see a good sample of what's supported in the April demo source files like this one: https://github.com/phantomics/april/blob/master/demos/dfns/array/array.apl
2:57:07
phantomics
One of the main differences to be aware of it that in user-defined operators, you use an underlined character like ⍹ to use the right operand as a value, and ⍵⍵ to use it as a function
2:57:25
phantomics
Handling the operands as either operands or functions is a real pain when compiling
2:58:40
phantomics
Guest92 other files: https://github.com/phantomics/april/blob/master/demos/dfns/numeric/numeric.apl https://github.com/phantomics/april/blob/master/demos/dfns/graph/graph.apl
3:01:50
phantomics
Gotcha, that behavior is undefined, afaik it will work in some situations but break in others
3:02:27
phantomics
Nameclasses are handled by accounting of symbols in a lexer postprocessing stage that happens after the lexer converts characters to tokens but before those tokens are fed to the compiler
3:03:00
Guest92
so why april, and not a standalone? How "serious" is april? As in is it yet another APL toy or does it have a longer term agenda?
3:03:56
phantomics
My goal is for April to be a professional-grade tool, not a toy. I'm using it in a hardware startup currently.
3:05:53
phantomics
For instance, check out the comment at the bottom of https://github.com/phantomics/april/blob/master/spec.lisp
3:06:29
phantomics
You'll see the syntax for extending April's idiom with a new function, you can make a function or operator out of any Unicode symbol you like, as well as customizing the grammar patterns and utilities
3:06:43
hayley
I'm starting to think I need an APL implementation so I don't lose my mind in data science classes. So the best move would clearly be to use cl4py and April to embed APL in Python.
3:07:32
phantomics
As far as interop patterns, I'm often writing CL functions that wrap around an (april-c) call
3:08:10
phantomics
There's a lot of depth to interop I have yet to explore via the :store-fn parameter
3:08:21
hayley
The other thing is that I need to write code in "Python", so downloading a language implementation manually is out of the question.
3:09:00
Guest92
so what is your development cycle for such functions when april-load needs a recompile?
3:09:36
lotuseater
it can also be greatly seen and used as kind of a very powerful DSL to shorten code even more :)
3:10:50
phantomics
I don't get why vector langs don't dominate in data science, they're vastly superior to any alternative for the field
3:10:57
saturn2
phantomics: you should probably make april-load expand to (eval-when (:compile-toplevel :execute) ...) rather than doing the work directly in the macro function
3:12:14
hayley
One fun example was counting the even numbers in an array. Should I write +/2|array or [x % 2 for x in array].count(0)? At least in Lisp we get COUNT-IF and EVENP.
3:14:28
moon-child
cl doesn't even have many good tools for tacit programming. I think the only thing I'm regularly able to do point-free is :key #'c*r and similar. But no compose, hook, partially apply, ...
3:14:30
hayley
I'd also like a better relational algebra library too; Pandas seems to be picky about the order of operations sometimes. And apparently it gets too slow with mere thousands of rows.
3:14:47
Guest92
phantomics I don't understand why the concept of a general programming notation is not dominating computer science in general
3:15:03
Guest92
array programming languages tend to not be able to differentiate between the notation and notation on arrays
3:15:47
moon-child
Guest92: the arrays are an essential aspect of the notation. https://www.reddit.com/r/apljk/comments/p4je0e/j_can_look_like_apl_vscode/h94ldvf/
3:15:58
phantomics
One annoying shortcoming in APL is the inability to specify a matrix in code without really hackneyed syntax like x⍪←1 2 3 ⋄ x⍪←4 5 6
3:16:15
Guest92
moon-childI knw that's the dogma from the iversonian camp, but I think a generalized programming notation is the benefit of APL, not MERELY the arrays
3:16:19
moon-child
Guest92: I distinguish left compose from right compose. ((lcompose f g) x y) ←→ (f (g x) (g y)). Whereas ((rcompose f g) x y) ←→ (f (g x y))
3:16:22
phantomics
But with April you can specify the matrix in CL like #2A((1 2 3)(4 5 6)) and then pass it into April
3:19:00
moon-child
so, not as a first-class combinator, but something you have to implement yourself
3:19:45
moon-child
obviously these are trivial to implement in any language with combinators. The question is, are those combinators primitive?
3:20:23
Guest92
https://codeberg.org/ndrogers/kpl/src/commit/58aa17d06c03d10ff8abc006263efce62c106037/apl.k#L75
3:20:42
moon-child
yes. Again, they can be trivially implemented in most languages. But they are not built in to most languages. That's all.
3:21:38
Guest92
moon-child I understand what you mean, Dyalog has many features of J because Roger Hui works for Dyalog now
3:24:23
beach
minion: memo for ln43: I think I introduced the problem you observed without noticing it, and then pushed the changes. So another pull would have fixed it.
5:36:53
Guest92
so I'm trying to define a package which depends on libraries and I want to then execute a primary function as a scrip
5:37:35
Guest92
i have an .asd file that has a :depends-on, and then I try to call a `sbcl --script file.lisp` that is mentioned in my .asd, but I don't think thats it
5:38:54
beach
I think you mean that you are trying to define a "system" rather than a "package", no?
5:44:41
White_Flame
CL has a history as an OS, and thus plays much better with the repl than external launching, though you can generate full executables
5:45:02
White_Flame
the scripting environment hasn't taken off that much, though there are some utilities to help launch from various OS's cmdlines
5:47:47
White_Flame
oftentimes to accomplish that, you'll build an executable image from the lisp that the other program can launch. That avoids portability issues
5:48:16
White_Flame
(portability between different CL implementations, launching from different users, etc, not OS portability ofc)
5:48:44
White_Flame
or, you have the lisp running as a server, and it receives requests from other programs
5:49:00
White_Flame
but certainly you can make a little scripting solution that works for your exact use environment setup
5:50:24
White_Flame
or sbcl --script, if your .lisp script file does (load "~/.sbclrc") as its first thing
5:51:53
White_Flame
the various options affect if the debugger is launched, does it automatically exit, etc
5:54:32
White_Flame
either it needs to be symlinked from ~/quicklisp/local-projects/, or added to your asdf:*central-registry* to be visible by default
5:58:55
Guest92
ah, so defpackage, then in-package, then the code I need with a (cl-user::exit) at the end does what I need
6:05:56
rain3
file.lisp: (defun main () (ql:quickload :your-app) (app:do-stuff) (sb-ext:exit)) sbcl --load file.lisp --eval "(main)"