montxero has quit [Remote host closed the connection]
knusbaum has joined #commonlisp
kevingal has quit [Ping timeout: 248 seconds]
waleee has quit [Ping timeout: 240 seconds]
markb1 has quit [Ping timeout: 250 seconds]
<skin>
Do the accessor or reader functions of a class get exported along with the class if I only export the class from a package?
<skin>
Or must I name the accessors in the export tag of defpackage
<mfiano>
only symbols are exported
<mfiano>
packages are not concerned with anything more than the identities of symbols
<mfiano>
Basically no, and this is why you should not name your slots a name that gets exported, since slots are an implementation detail that bypass any behavior your protocol provides.
<skin>
Right
<skin>
So you can export the name of the class without the slots interesting
<edwlan[m]>
You only export symbols
<skin>
True but the name of the class is a symbol
<skin>
But I suppose the distinction is interesting
<edwlan[m]>
if you don't export the symbol that names a slot, you don't export any way to access the slot
<mfiano>
You control your public interface through exports on a symbol by symbol basis. It's important to pay attention to the names of things you export (the symbols), and be absolutely sure you didn't know some other construct with the same symbol if you do not want users to think that it is also public.
<edwlan[m]>
(access the slot by name, you could export a function that accesses the slot)
<mfiano>
s/know/have/
<edwlan[m]>
I typically define my slots like (%foo :reader foo :initarg :foo)
<mfiano>
As do I and quite a few others
mason has quit [Quit: leaving]
mason has joined #commonlisp
ym has joined #commonlisp
markb1 has joined #commonlisp
raemac has joined #commonlisp
triffid has quit [Remote host closed the connection]
triffid has joined #commonlisp
triffid has quit [Remote host closed the connection]
azimut has joined #commonlisp
<skin>
Indeed, that's what I do as well
antonv has joined #commonlisp
<antonv>
Hi
<antonv>
What library has a binary search function for arrays?
<mfiano>
serapeum would be one.
<antonv>
seems to be a great library, but I can't find binary search there...
<skin>
Seems like every time I need binary search for arrays, what I really need is a red black binary tree
<skin>
Why make a list and keep it sorted when you could just use that
<skin>
In which case, I would use the FSet library
<beach>
Because, if your data does not evolve very often, a binary search of a vector is much more efficient than searching a tree.
ym has quit [Remote host closed the connection]
<beach>
Again, you must first determine the use pattern and only then decide what data structure is best.
<skin>
Fair, but binary tree is usually good enough
<beach>
*sigh*
<skin>
And if it really matters, the performance, then why use common lisp instead of something a bit closer to the metal
<antonv>
My data is static.
<antonv>
Actually, linear search would work well
<skin>
That kind of optimization of something I would expect from databases or filesystems. Anyway, I get the static data thing
<antonv>
What I am doing is mapping character position of a source file to a line number
<antonv>
Because I want docs to have references to function source code on github
<antonv>
Cool coincidence that serapeum does the same :)
<beach>
antonv: I would think you need a linear search then, because you need to count newlines, no?
<skin>
Yeah I don't see how binary search maps here
<antonv>
I planned to read the file once, and produce an array, one element for each line. The element value is character position of that line.
<skin>
Thus a vector with monotonically increasing values
<antonv>
Yes
<skin>
I see
<skin>
Well, I'd be interested in knowing which one does that too I guess
<antonv>
I wanted to consult swantk to find definition of symbols, and as swank gives character positions, I needed to map that to line numbers.
<skin>
It's one of those functions that's super trivial to implement but you just wish everyone would agree on which one we all use
<ixelp>
serapeum/docs.lisp at master · ruricolist/serapeum · GitHub
<antonv>
So for every symbol they simply read whole file into a string, and count newlines
<antonv>
Comparing to that my wish for binary-search instead of simple linear search is a gross overoptimization :)
<antonv>
Still curious to know, if there is a binary search function
<antonv>
mfiano: are you sure serapeum has a binary-search? I don't see it
<mfiano>
Another name for binary search is 'bisect'
<antonv>
cool, thank you
rgherdt has joined #commonlisp
<mfiano>
It's a very easy function that I think every computer programmer should know how to write. It does have one edge case to handle that I often see beginners implement wrongly.
<mfiano>
But other than that, I suggest writing one that fits your problem best. Then you may better understand it.
<beach>
And most text books on algorithms do it wrong to, in that their implementation uses twice as many tests as required.
<mfiano>
exactly
<antonv>
does ChatGPT write it correctly?
<mfiano>
That depends on the input parameters I would assume.
shka has joined #commonlisp
<antonv>
I wanted to avoid writing it myself and use a library.
<antonv>
Maybe I need to excersize more, but it's difficult for me to reason clearly to be sure some corner case is not unaccounted.
<antonv>
And be careful with indexes.
<antonv>
How much time it would take me to implement it correctly? 10 mins? half an hour? more?
<antonv>
I don't know
Perflosopher has quit [Quit: Ping timeout (120 seconds)]
antonv has quit [Remote host closed the connection]
<beach>
jcowan: Yes, the asymptotic complexity is the same. But that's not what I was referring to.
slyrus has quit [Remote host closed the connection]
pve has joined #commonlisp
antonv has joined #commonlisp
attila_lendvai has joined #commonlisp
msavoritias has joined #commonlisp
igemnace has joined #commonlisp
LW has joined #commonlisp
minion has joined #commonlisp
LW has quit [Client Quit]
minion has quit [Remote host closed the connection]
slyrus has joined #commonlisp
slyrus has quit [Ping timeout: 268 seconds]
raemac has quit [Ping timeout: 250 seconds]
<antonv>
I am done
<antonv>
Less than two hours
<beach>
Congratulations!
<antonv>
Thanks
<antonv>
That was a super difficult exercise
<beach>
It is easy to get it wrong, even for experienced people, as the textbooks show.
minion has joined #commonlisp
minion has quit [Remote host closed the connection]
minion has joined #commonlisp
minion has quit [Remote host closed the connection]
<antonv>
For me the difficulty is how the space of possibile approaches multiply thus overwhelming my brain's capacity
Brucio-61 has joined #commonlisp
<antonv>
I implemented something near correct very quickly and then was struggling to understand what my function shoudl return
<antonv>
Initially was thinking I am searching for an element, but what if the element is absent
<beach>
Then again, maybe textbook authors are not necessarily experienced programmers.
<antonv>
Even after figuring out what the function must return, the space of approaches is large
<beach>
antonv: Yes, my version gives the position of the element if it is present, and a position to insert it if it is not present.
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
<antonv>
I definitely don't have enough training and skill to reason systematically and "synthesize" a solution as a kind of straight path by "contraint satisfaction" of the task.
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
<beach>
You may be in good company. I probably spent years thinking about problems like this, of and on of course. It is not clear that I would have come up with the right thing the first time.
slyrus has quit [Ping timeout: 240 seconds]
<antonv>
beach: the main error in your solution is that it returns start instead of end
<beach>
It doesn't matter since they differ by exactly 1.
<beach>
But I don't think it is an error actually.
<antonv>
depends on how you define "insert" what happens with the element already at this position - does it move right or left
<beach>
For insertion, I imagined sliding all existing objects after the position one step to the right.
<splittist>
you need to be able to insert at 0 and (length arr),
<antonv>
I fixed your draft to make it compile (changed V to VECTOR, added the division), and added default values
<splittist>
(eventually)
<antonv>
(binary-search #(1 9) 3) => 0
<beach>
antonv: Fair enough, I could have returned END.
<antonv>
or treat the insertion as "put new element after the position, and slide everything else to the right"
<splittist>
Return the item or a lambda with one argument, the item to be inserted (:
* splittist
stops
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
minion has joined #commonlisp
slyrus has joined #commonlisp
minion has quit [Remote host closed the connection]
minion has joined #commonlisp
minion has quit [Remote host closed the connection]
minion has joined #commonlisp
minion has quit [Remote host closed the connection]
rogersm has quit [Quit: Leaving...]
minion has joined #commonlisp
minion has quit [Remote host closed the connection]
<antonv>
After regaining some confidence, that I can write basic algorithm, even if slowly, I am returing to my task with docs.
<antonv>
I think one of the best way for API reference is to have package.lisp file clickable
minion has joined #commonlisp
<antonv>
You can click an exported sybmol and to to the function definition
<antonv>
In this case the package.lisp is like CLHS-style dictionary
minion has quit [Remote host closed the connection]
specbot has joined #commonlisp
<antonv>
Low effort for maintainer, and encourages to keep package lisp well organized and friendly for readers.
specbot has quit [Remote host closed the connection]
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
slyrus has quit [Ping timeout: 260 seconds]
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
minion has joined #commonlisp
minion has quit [Remote host closed the connection]
minion has joined #commonlisp
minion has quit [Remote host closed the connection]
slyrus has joined #commonlisp
attila_lendvai has quit [Read error: Connection reset by peer]
<antonv>
BTW, one example of how "combinatorial explosion" of possibilities to explore overwhelmed my brain during the bisect excersize. I was thinking, what is the middle element accidentially hits the value we search. Ignoring that and continuing search seemed wasteful. So should the termination condition be based on the middle element? Just of of the many possible "branches" to explore when thinking of a solution.
<beach>
That solution is what gives twice as many tests as necessary on the avarage.
<beach>
average
minion has joined #commonlisp
attila_lendvai has joined #commonlisp
minion has quit [Remote host closed the connection]
<antonv>
It's not obvious when this thought just appearsh. The hope is to find some concise expression, based on a single test of the middle element.
slyrus has quit [Ping timeout: 240 seconds]
<beach>
Right. Again, it is not obvious. But when presumably experienced people who write text books get it wrong, that's very strange to me.
<antonv>
Maybe they do it on some pedagogical purpose?
<beach>
Nah, they are just doing it wrong.
<beach>
I mean, it is strange to me, but I am not that surprised anymore, given the number of mistakes and errors I see in text books written by presumably experienced people.
<antonv>
I found a bug in my version: (my-bisect #(1 777) 1 #'<) => 1
<antonv>
Only happens when the first element is equal to the searched VAL
kurfen_ has quit [Ping timeout: 260 seconds]
kurfen has joined #commonlisp
<antonv>
just forgot about the equality when establishing the invariant
minion has quit [Remote host closed the connection]
minion has joined #commonlisp
minion has quit [Remote host closed the connection]
slyrus has quit [Ping timeout: 276 seconds]
david` has joined #commonlisp
morganw has joined #commonlisp
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
_cymew_ has joined #commonlisp
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
minion has joined #commonlisp
minion has quit [Remote host closed the connection]
minion has joined #commonlisp
slyrus has joined #commonlisp
minion has quit [Remote host closed the connection]
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
easye has quit [Remote host closed the connection]
easye has joined #commonlisp
minion has joined #commonlisp
minion has quit [Remote host closed the connection]
minion has joined #commonlisp
minion has quit [Remote host closed the connection]
karlosz has joined #commonlisp
minion has joined #commonlisp
minion has quit [Remote host closed the connection]
rgherdt_ has joined #commonlisp
minion has joined #commonlisp
minion has quit [Remote host closed the connection]
minion has joined #commonlisp
minion has quit [Remote host closed the connection]
rgherdt has quit [Ping timeout: 240 seconds]
slyrus has quit [Ping timeout: 268 seconds]
slyrus has joined #commonlisp
slyrus has quit [Ping timeout: 240 seconds]
antonv has quit [Remote host closed the connection]
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
slyrus has joined #commonlisp
minion has joined #commonlisp
minion has quit [Remote host closed the connection]
minion has joined #commonlisp
minion has quit [Read error: Connection reset by peer]
slyrus has quit [Ping timeout: 268 seconds]
Gleefre has quit [Ping timeout: 245 seconds]
edgar-rft has quit [Quit: Leaving]
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
minion has joined #commonlisp
minion has quit [Remote host closed the connection]
karlosz has quit [Quit: karlosz]
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
slyrus has joined #commonlisp
slyrus has quit [Ping timeout: 240 seconds]
jeosol has quit [Quit: Client closed]
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
random-nick has joined #commonlisp
slyrus has joined #commonlisp
slyrus has quit [Ping timeout: 240 seconds]
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
karlosz has joined #commonlisp
slyrus has joined #commonlisp
jonatack has quit [Ping timeout: 240 seconds]
jonatack has joined #commonlisp
slyrus has quit [Ping timeout: 276 seconds]
kevingal has joined #commonlisp
easye has quit [Ping timeout: 240 seconds]
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
easye has joined #commonlisp
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
minion has joined #commonlisp
minion has quit [Remote host closed the connection]
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
minion has joined #commonlisp
minion has quit [Remote host closed the connection]
rgherdt_ is now known as rgherdt
minion has joined #commonlisp
minion has quit [Remote host closed the connection]
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
minion has joined #commonlisp
minion has quit [Remote host closed the connection]
specbot has joined #commonlisp
specbot has quit [Remote host closed the connection]
<skin>
Good morning from the American mountain West.
kevingal has quit [Ping timeout: 260 seconds]
slyrus has joined #commonlisp
<beach>
Hello skin.
kevingal has joined #commonlisp
jeosol has joined #commonlisp
slyrus has quit [Ping timeout: 248 seconds]
msavoritias has quit [Remote host closed the connection]
grawlinson has quit [Ping timeout: 246 seconds]
slyrus has joined #commonlisp
grawlinson has joined #commonlisp
<skin>
You said something earlier before I went to bed about choosing the right algorithm. Binary search a vector instead of a tree of the situation called for it.
<skin>
It's idiomatic then to be more rigorous?
<skin>
I suppose it makes sense
<skin>
Just more of my clojure showing unfortunately. That community is a bit more like Python in its goals
<skin>
Sometimes I forget that common lisp is largely a compiled language.
<beach>
Er, what? Languages are (usually) neither interpreted nor compiled. That is the choice of a particular implementation.
<skin>
Lispers often say this
<skin>
But it is not practically true in my opinion
<beach>
I am sorry to hear that Lispers often say that. But I have no statistics to support it.
<skin>
Perhaps it's because lisp is such a flexible language that it doesn't care about its implementation
<skin>
You can have common lisp on the JVM you can have common lisp interpreted you can have common lisp compiled
<skin>
It's actually really cool
<skin>
It's not something most languages can pull off
<beach>
It is true for most languages. C is neither compiled nor interpreted.
<skin>
That is true strictly speaking. But here is my point on that I think
<skin>
I'm a DevOps engineer by trade
<skin>
I have been called on in my career to take a language that is typically interpreted and compile it
<skin>
CX freeze in python does this
<skin>
Tries to compile Python down to native stuff
<skin>
Basically it's a really hard road and it doesn't work very well
<skin>
Mostly because of tooling and community
<skin>
I'm rattling on but I'm trying to be brief.
<skin>
In short I think the minds of programmers in that community assume a certain runtime and they write their libraries accordingly
<skin>
Python doesn't have to have a gil but so much code is run with a gil that there's a lot of tooling and libraries around running sub-processes of python more than there are around multi-threading
<skin>
At least for CPU performance
<beach>
Most programmers are not very competent, so I wouldn't pay much attention to their assumptions.
<skin>
Sure
hayley has quit [Quit: Bridge terminating on SIGTERM]
edgarvincent[m] has quit [Quit: Bridge terminating on SIGTERM]
kakuhen has quit [Quit: Bridge terminating on SIGTERM]
<skin>
But the hive mind is an asset
paulapatience has quit [Quit: Bridge terminating on SIGTERM]
BrownJenkin has quit [Quit: Bridge terminating on SIGTERM]
Mrtn[m] has quit [Quit: Bridge terminating on SIGTERM]
Duuqnd has quit [Quit: Bridge terminating on SIGTERM]
jryans has quit [Quit: Bridge terminating on SIGTERM]
bitblit1 has quit [Quit: Bridge terminating on SIGTERM]
char[m] has quit [Quit: Bridge terminating on SIGTERM]
DouglasRMiles[m] has quit [Quit: Bridge terminating on SIGTERM]
alanz has quit [Quit: Bridge terminating on SIGTERM]
emacsomancer[m] has quit [Quit: Bridge terminating on SIGTERM]
edwlan[m] has quit [Quit: Bridge terminating on SIGTERM]
yitzi has quit [Quit: Bridge terminating on SIGTERM]
roygbyte[m] has quit [Quit: Bridge terminating on SIGTERM]
AadVersteden[m] has quit [Quit: Bridge terminating on SIGTERM]
usop[m] has quit [Quit: Bridge terminating on SIGTERM]
nicm[m] has quit [Quit: Bridge terminating on SIGTERM]
infra_red[m] has quit [Quit: Bridge terminating on SIGTERM]
luffy[m]1 has quit [Quit: Bridge terminating on SIGTERM]
JonBoone[m] has quit [Quit: Bridge terminating on SIGTERM]
loke[m] has quit [Quit: Bridge terminating on SIGTERM]
Gnuxie has quit [Quit: Bridge terminating on SIGTERM]
<skin>
Talking to you about it though is crystallizing my opinion I think
<skin>
You're right it's not about the language.
<beach>
By the way, Python is more like a programming system than like a language. To qualify as a language, it should have a specification that is independent of the crowd that supplies implementations.
<skin>
It's probably more about the community. If everyone assumes that everyone else's code is going to be on a similar run time it greases the wheels. Makes it easier to make assumptions and reuse other people's code
Perflosopher has quit [Ping timeout: 240 seconds]
<skin>
The common lisp community is united but also composed of many tiny smaller communities. Like ancient Greece or modern Europe
<skin>
It's very democratic that way.
<skin>
beach: Yes the CL standard is definitely an asset. It took crazy long too. 8 years
<skin>
It puts R7RS discussions into perspective. I wonder how they're going maybe I'll join a scheme channel and see how it's running
<beach>
How does the community idea affect compilation vs interpretation? Or is this a new idea?
<skin>
Take choice of binary tree or vector for example
edgarvincent[m] has joined #commonlisp
<john_titor>
I think that the problem with r7rs is that they did not get many people on board (i.e implementers)
Mrtn[m] has joined #commonlisp
Gnuxie has joined #commonlisp
yitzi has joined #commonlisp
kakuhen has joined #commonlisp
AadVersteden[m] has joined #commonlisp
char[m] has joined #commonlisp
Duuqnd has joined #commonlisp
BrownJenkin has joined #commonlisp
paulapatience has joined #commonlisp
<skin>
Why optimize further and choose a faster vector when the code is going to be interpreted and therefore slow anyway
loke[m] has joined #commonlisp
slyrus has quit [Ping timeout: 240 seconds]
<skin>
john_titor: interesting
roygbyte[m] has joined #commonlisp
edwlan[m] has joined #commonlisp
alanz has joined #commonlisp
bitblit1 has joined #commonlisp
<skin>
Why does Python use reference counting instead of proper garbage collection
JonBoone[m] has joined #commonlisp
jryans has joined #commonlisp
hayley has joined #commonlisp
<skin>
Because it makes it much much easier to call c code
<skin>
Another example of platform enabling community interaction
emacsomancer[m] has joined #commonlisp
usop[m] has joined #commonlisp
luffy[m] has joined #commonlisp
DouglasRMiles[m] has joined #commonlisp
<john_titor>
I think that you speak nonsense
infra_red[m] has joined #commonlisp
nicm[m] has joined #commonlisp
<beach>
It doesn't make much sense to me either.
<skin>
It's fun to put my opinions here because most people don't challenge them in other places. I always learn something new
<hayley>
Boehm famously proclaimed that threads cannot be implemented as a library; allowing for true parallel execution introduces more non-determinism that Python may not have.
<skin>
Why can't they be implemented as a library
<john_titor>
rusing people on the internet with stating incorrect things is infamously a better way to get answers than asking questions
<skin>
They can but that would incur trade-offs that Boehm didn't like
<skin>
Likely for good reasons
<skin>
To be clear I am not trying to ruse anybody. I apologize if that's how I came off
<skin>
These are my true opinions
<skin>
But I'm happy to have them changed and improved
minion has joined #commonlisp
specbot has joined #commonlisp
<hayley>
Threads can't be correctly implemented as a library, because a compiler could use optimisations which are only correct without threads.
<hayley>
That issue specifically is not too relevant to Python, but I mean to illustrate that threading is a significant issue for a programming language.
Perflosopher has joined #commonlisp
<skin>
Forgive me for my ignorance I'm trying to understand what you said
<skin>
I think you're saying that threads can't be correctly implemented as a library in a compiled language without significantly affecting performance (missing out on compiler optimizations)
<hayley>
No, I'm not.
<skin>
Ok.
<skin>
Read it again
<skin>
If you implement threads as a library the compiler could sabotage your code with optimizations that you're not thinking about
<hayley>
It's kinda backwards from that.. Suppose we had a language without threads. A correct implementation of that language could use optimisations which so happen to break threads-implemented-as-libraries.
<skin>
Right I'm getting it now
<hayley>
Right. And the compiler is doing its job just fine here.
<hayley>
I can't find a specification of how threads work in Python, but maybe I didn't search hard enough. Depending on what the specification says, it may indeed be the case that a Python implementation does have to use a global lock to get the right semantics.
tyson2 has joined #commonlisp
<hayley>
To be more on topic, in my opinion the memory model of Bordeaux threads for Common Lisp is underspecified, too, in a similar manner to what Boehm states of ptherads for C.
piethesailor has joined #commonlisp
Noisytoot has quit [Ping timeout: 240 seconds]
<beach>
Bike was working on a memory model I think, but not in the context of Bordeaux threads I guess.
<hayley>
Right.
Noisytoot has joined #commonlisp
slyrus has joined #commonlisp
Noisytoot has quit [Remote host closed the connection]
Noisytoot has joined #commonlisp
slyrus has quit [Ping timeout: 246 seconds]
slyrus has joined #commonlisp
NotThatRPG has joined #commonlisp
NotThatRPG is now known as NotThatRPG_away
slyrus has quit [Ping timeout: 264 seconds]
NotThatRPG_away has quit [Ping timeout: 246 seconds]
elevenkb has joined #commonlisp
waleee has joined #commonlisp
slyrus has joined #commonlisp
Brucio-61 has quit [Ping timeout: 260 seconds]
tevo has quit [Ping timeout: 240 seconds]
edgar-rft has joined #commonlisp
slyrus has quit [Ping timeout: 240 seconds]
<czy>
what is the difference between :all and :toplevel in the :export clause of 'defpackage?
<ixelp>
Writing Small CLI Programs in Common Lisp / Steve Losh
<phoe>
in such syntax, :ALL and :TOPLEVEL are actually symbols that act as string designators and this equivalent to (defpackage ... (:export #:all #:toplevel)) which I personally prefer
<phoe>
or (defpackage ... (:export "ALL" "TOPLEVEL")) but only assuming default reader settings
<czy>
oh, i see. can you still give the package a shorter nickname if using (:export #:all)?
fourier_ is now known as fourier
<phoe>
I don't understand how these two things are related
<phoe>
nicknames are controlled via :NICKNAMES while :EXPORT exports symbols from package
<beach>
czy: :all, #:all, "ALL" are all string designators that designate the same string, which is just the name of a symbol to export. It has no other meaning to DEFPACKAGE.
<czy>
so when i do something like (defpackage :foo (:use :cl) (:nicknames :f) (:export :all)), when i try to call #'f:bar in some other package, CL would complain that #'f:bar is not internal to such a package
<phoe>
this is correct
<phoe>
you need to (:export #:bar)
<czy>
beach: oh, so it does not mean "exporting all symbols in this package"?
<phoe>
(:export #:all) only exports the symbol named "ALL"
<beach>
czy: Correct.
<czy>
oh, my damn ass.
<phoe>
just like (:export #:nothing) exports a symbol named "NOTHING"
<czy>
is there a way to export all symbols in the DEFPACKAGE macro, or that is something i have to write myself
<phoe>
probably the latter, you usually don't want to export all internal symbols of a package
<beach>
czy: You would not want to export all symbols anyway. There are plenty of symbols such as I, COUNT, FOR, that are just names of lexical variables.
<czy>
fair enough.
<phoe>
you can also use :: to ignore externality, so #'f::bar will work too
<czy>
phoe: that's what i have been using
<phoe>
oh, good; then you can figure out what you want to export and actually export that stuff and then switch to a single colon
<czy>
i wish there is a way to export all the symbols generated by #'defstruct or #'defclass
<beach>
czy: It looks to me like you are using the package system in a strange way. It is meant for you to export symbols that are part of the API, and if you can't decide what the API is, you are in trouble.
<john_titor>
czy: if you don't want to settle on a declarative package definition where you know what you are implementing and making available to the world, then you may use a library cl-annot (I think that's how it is called)
<czy>
beach: you are not wrong, i am still trying to figure out how to write CL
<ixelp>
GitHub - m2ym/cl-annot: Python-like Annotation Syntax for Common Lisp
<john_titor>
it has some fancy syntax like @export
<czy>
oh, interesting!
<czy>
john_titor, phoe, thank you
<phoe>
but beware that this is non-standard stuff and some lispers might be allergic to custom syntax like that
<john_titor>
and if you want to throw in a towel and export all symbols then you may always do as the last thing after loading your source code (do-symbols (s your-package) (export s your-package))
<czy>
maybe i should just use alists over structs? i feel like that is more natural in lisp
slyrus has joined #commonlisp
<john_titor>
use standard classes
<john_titor>
and if you want to squeeze some performance (i.e you confirm that there is a bottleneck due to CLOS), descend to structures
<john_titor>
alists are pita to work with (not to mention they are terrible performance-wise)
<phoe>
czy: there's nothing wrong with using structures or classes in CL, lists are often inconvenient
<john_titor>
if you must, use hash-tables instead
<john_titor>
you better trust me, I've came from the future ,)
<phoe>
in particular there's no good type information associated with lists and you can't write methods that specialize on lists
<phoe>
...lists containing different sorts of elements, I mean
<john_titor>
it is a generic function that specializes to something, not method
<czy>
( ´_ゝ`) i often find myself serialize my data into alists and then deserialize it from alists
<phoe>
john_titor: wat
<phoe>
where do you put specializers in GF, then
<phoe>
...golly, it is a loaded question, isn't it
<john_titor>
the form defmethod adds a new specialization to the generic function in a form of a new method, but method itself is not specialized
<john_titor>
it is specialization itself (of the generic function)
* phoe
needs to parse this, hold on
<john_titor>
I've came from the future, trust me
<john_titor>
i.e method specializes the generic function, not types specialize the method
<john_titor>
s/types/classes/
<john_titor>
I can hear pages of clhs turning from multiple directions
<phoe>
you might be right
<phoe>
both about the pages turning and the specialization
<john_titor>
\o/
<john_titor>
to make things funny, method maintains a list of specialzers itself for each argument :)
<john_titor>
all in all - whoever defined clos and mop could do a bit better job with terminology (not that I could do half of what was done)
<john_titor>
s/half/even half/
ym has joined #commonlisp
lucasta has joined #commonlisp
<czy>
do people usually export all the accessors generated by DEFCLASS by hand or just use double colon :: to access them?
<beach>
czy: Neither.
<beach>
czy: You export only the accessors that are part of the API.
<beach>
And you do that "by hand" because the system can't decide that for you.
<beach>
*you export only the NAME OF THE accessor
<czy>
that's fair, i guess that is the price of freedom ( `ー´)
NotThatRPG has joined #commonlisp
attila_lendvai has quit [Read error: Connection reset by peer]
attila_lendvai has joined #commonlisp
<beach>
It is the same thing for almost every language. You split your code into modules and only the API-related stuff is exported from each module.
Brucio-61 has joined #commonlisp
<czy>
right, i guess ML modules pretty much in the same way. things one puts in the signatures gets to be accessible
Brucio-61 has quit [Ping timeout: 260 seconds]
Brucio-61 has joined #commonlisp
alejandrozf has joined #commonlisp
piethesailor has quit [Ping timeout: 246 seconds]
<splittist>
czy: if you are a mere mortal, you might not know what your api is while you are still writing it, so feel free (as was said above) to use :: when developing. Then, when you have a feel for what the appropriate api/abstractions/protocol is, you can make your export decisions. This will then guide users of your package (including future you) as to how things are to be approached.
piethesailor has joined #commonlisp
<john_titor>
usually people level up to immortality after: 1) writing your own testing framework, 2) writing our own common lisp implementation, 3) writing your own json parsing library, 4) writing your own lisp operating system (listed in order of difficulty)
<john_titor>
that's why lispers erwrite them over and over again
<john_titor>
rewrite*
<phoe>
you got the order wrong
<john_titor>
json should go after the operating system?
<phoe>
writing a correct json parser library is harder than writing a lisp os
<phoe>
yes
<john_titor>
OK, this one goes to you ,) /me needs to go, laters \o
piethesailor has quit [Remote host closed the connection]
jonatack has quit [Ping timeout: 260 seconds]
jonatack has joined #commonlisp
alejandrozf has quit [Remote host closed the connection]
Alfr has quit [Quit: Leaving]
jon_atack has joined #commonlisp
slyrus has quit []
jonatack has quit [Ping timeout: 265 seconds]
elevenkb has quit [Read error: Connection reset by peer]
zxcvz has joined #commonlisp
lucasta has quit [Ping timeout: 265 seconds]
<czy>
splittist: i'd wish i am immortal though
piethesailor has joined #commonlisp
lucasta has joined #commonlisp
dcb has joined #commonlisp
cage has joined #commonlisp
tyson2 has quit [Remote host closed the connection]
tibfulv has quit [Remote host closed the connection]
tibfulv has joined #commonlisp
<edwlan[m]>
I’m not sure there’s such a thing as a correct json parsing library
<edwlan[m]>
There’s a spec, but it has enough latitude that different conforming implementations can interpret the same document differently
<edwlan[m]>
And there’s a class of security issues that work by writing documents that are parsed one way by the security checks and another way by the application code
jon_atack has quit [Ping timeout: 248 seconds]
raemac has joined #commonlisp
zxcvz has quit [Quit: zxcvz]
jon_atack has joined #commonlisp
Cymew has quit [Ping timeout: 268 seconds]
<NotThatRPG>
Could anyone clue me in about interning, uninterning, and shadowing? I'm trying to override the version of SUBTYPEP invoked by Alexandria (in a test) by (1) uninterning alexandria::subtypep (2) shadowing alexandria::subtypep (3) setting the symbol-function of alexandria::subtypep (4) invoking alexandria:type= (which calls subtypep). For whatever reason, 4 seems to invoke cl:subtypep
<NotThatRPG>
I had hoped that subtypep would be invoked by looking up the symbol function of alexandria::subtypep but that assumption seems to be erroneous.
<NotThatRPG>
or, as we say, "dead wrong."
<phoe>
in a test?
<phoe>
you mean that you try to do this from outside Alexandria?
<semz>
Wouldn't the cl:subtypep symbol that the def of alexandria:type= (still) refers to be a different symbol than alexandria::subtypep
<phoe>
^
<semz>
assuming that the implementation doesn't outright opencode cl:subtypep
jeosol has quit [Quit: Client closed]
<phoe>
alexandria would need to do stuff like (funcall (find-symbol "SUBTYPEP") ...) in order to force symbol lookup at runtime
<phoe>
and that would be damn weird
<Bike>
the alexandria package USEs the CL package, so when you see (SUBTYPEP ...) in the alexandria code (read in the alexandria package), that _is_ cl:subtypep
<Bike>
there is no distinct alexandria::subtypep symbol.
<phoe>
Bike: shadowing is stronger than using though, isn't it?
<NotThatRPG>
phoe, Bike : that's what I was afraid of.
<phoe>
I assume NotThatRPG is trying to make a new a::subtypep symbol
<phoe>
and then "hook it up" in place
<NotThatRPG>
phoe: Yes, that is right. I am trying to inject a "mock" subtypep into alexandria:type= to test it.
<Bike>
if you're willing to edit alexandria's source code, you can just do that and not bother with package silliness. if not, you're out of luck.
<NotThatRPG>
Bike: AFAICT that would involve damaging alexandria in order to test it.
<phoe>
or copying that piece of code out
<Bike>
practically speaking what i'd do is just copy the definition of type= somewhere else, yes. it's not that complicated. but maybe that makes it hard to use the test suite or something.
<phoe>
or doing some macro witchcraft to get a custom copy of TYPE= that calls your custom SUBTYPEP instead of the standard one
<NotThatRPG>
phoe: Right, but then I am testing that piece of code, instead of testing type= (which could be changed without changing the copy). This is really nasty
<Bike>
alexandria:type= is defined in terms of cl:subtypep. if you want a type= with a different subtypep, that is no longer the existing alexandria:type=
<NotThatRPG>
phoe: Probably the macro witchcraft is the best I could do. That kind of makes sense: I can define alexandria::testable-type=
<NotThatRPG>
Bike: What I am trying to do is to test what type= does *depending on known return values from subtypep*
<splittist>
compile it to bytecode and hook into the vm /;
<NotThatRPG>
Bike: Otherwise I have to find an exhaustive set of type combinations *that work identically across implementations* which seems impossible (in practical terms).
<Bike>
based on known return values? like you want to see what it does for every permutation of results you can get from (subtypep type1 type2) and (subtypep type2 type1)?
<NotThatRPG>
Bike: Yes! Exactly!
tyson2 has joined #commonlisp
<Bike>
i'm... confused. the function is simple enough that you can do that just by looking at it.
<NotThatRPG>
Bike: I wanted to demonstrate (a) the current implementation is wrong and (b) the patch fixes the error.
<NotThatRPG>
Since clearly it is possible for TYPE= to do the wrong thing without detection by the community at large.
<Bike>
if i understand correctly, i would be inclined to just explain the problem in natural language rather than muck around with package arcana
<phoe>
or provide the return values for the two SUBTYPEP calls
<Bike>
or, if you have a particular example of subtypep results that lead to incorrect type= results, show that off
<NotThatRPG>
I suppose I should just give up, make an MR with no test and let the chips fall where they may.
<Bike>
out of curioity, what is the problem?
<Bike>
i say as someone who's done way too many truth tables in the course of implementing subtypep
<edwlan[m]>
Can’t you do something like:
<edwlan[m]>
(eql (type= a b) (and (suptypep a b) (suptypep b a))) in the test?
<NotThatRPG>
Bike: A branching structure that is more elegant and less readable hides an error in computing the second return value for TYPE= -- it's possible for one of the two SUBTYPEP calls to return a second value of NIL and TYPE= to return a second value of T
<phoe>
edwlan[m]: multiple values probably come into play
<edwlan[m]>
And then pick values of a and b that demonstrate the problem?
<edwlan[m]>
Add nth-value then
<Bike>
NotThatRPG: is that not correct? if A is definitely not a subtype of B, A and B are definitely not type=, regardless of how sure it is about whether B is a subtype of A.
<phoe>
if (subtypep a b) is NIL NIL and (subtypep b a) is NIL T, then the two types are distinct
<Bike>
yeah, that.
<phoe>
because NIL T is the only case in which they must NOT be equal
<phoe>
any combination of T T and NIL NIL means "yes" or "maybe" but never "no"
* john_titor
feels that producing himself yesterday to advice NotThatRPG was a wasted effort
<NotThatRPG>
Will reread. Certainly TYPE= could use a comment or two -- that logic is pretty arcane
<phoe>
it's just the mathematical notion of set equality
<phoe>
since CL types are math sets
<Bike>
everything about the type system is kind of arcane.
<Bike>
it is just set theory, except having the trivalent results takes you far afield from conventional textbook
<phoe>
two sets A and B are equal IFF A is a subset of B AND B is a subset of A
<phoe>
if either of these two branches goes false, then the sets are not equal because of how logical implication works
<NotThatRPG>
Bike: it's just the truth table that is implicit in that COND is not explained clearly...
<phoe>
so the other one can be whatever
<Bike>
it is not explained clearly in the code, no
<phoe>
yeah it's three-value logic in play so it might be confusing
<Bike>
when i wrote ctype i put in comments of algebraic notation that i worked through in order to convince myself the code was correct
<NotThatRPG>
We can get to the third branch from T NIL and then from the second check get T T and we get NIL T out, right?
<ixelp>
ctype/disjunction.lisp at main · s-expressionists/ctype · GitHub
<phoe>
T NIL is not an option
<phoe>
like, SUBTYPEP can return T T or NIL NIL or NIL T
<john_titor>
T NIL "rather maybe yes, fingers crossed!"
* john_titor
is joking
<phoe>
T NIL == "not sure better reread the spec mate"
<NotThatRPG>
Ah! That's right. I think I may have seen this happening in one of the tests, which led me down this rabbit-hole. I wonder if some implementation figured that since the second value (should be) a don't care if the first was T and just returned T instead of (values T T)?
<Bike>
if an implementation is returning T NIL it's broken.
<phoe>
CLHS SUBTYPEP, "(The second value is always true when the first value is true.)"
<Bike>
it is conceptually kind of a don't-care, but the spec is pretty clear that if the first value is true so must be the second.
<phoe>
T NIL would not conform
<NotThatRPG>
Bike: I have indeed found (and reported) some broken SUBTYPEP implementations in checking the alexandria tests.
<Bike>
unsurprising
<Bike>
when i was fussing with this stuff i actually managed to find a minor bug in sbcl's subtypep
<NotThatRPG>
One subtypep check returns NIL NIL and one T T -- shouldn't that be NIL NIL? We aren't sure that the first check is correct, so it's possible that the types are equal...
jon_atack has quit [Quit: WeeChat 3.8]
<Bike>
yes, i think that should be NIL NIL.
<john_titor>
NotThatRPG: if /any/ subtypep returns the second value as NIL, then type= should return NIL NIL
* john_titor
has been repeating that yesterday a few times
<NotThatRPG>
OK, so TYPE= *is* wrong...
<Bike>
john_titor: we actually just said that if one returns NIL T and the other returns NIL NIL, type= should return NIL T.
<john_titor>
you are correct, apologies
<Bike>
no problem
<Bike>
NotThatRPG: i hope your MR puts a truth table in a comment, since that's just about the only way to understand this stuff
<Bike>
i ended up writing a bunch of trivalent operators, so type= is "just" (tri/and (subtypep t1 t2) (subtypep t2 t1)), and then the confusion moves to how tri/and is defined
<ixelp>
ctype/trivalent.lisp at main · s-expressionists/ctype · GitHub
<NotThatRPG>
I have a first draft, but I think it needs distillation. This is more me working through the possibilities in code: https://pastebin.com/M9R0U8fm
<ixelp>
First draft - Pastebin.com
<NotThatRPG>
That final cond can obviously be simplified...
<NotThatRPG>
I am going to step away from the keyboard slowly, since the room is starting to rotate around me....
Alfr has quit [Read error: Connection reset by peer]
ym has quit [Remote host closed the connection]
<john_titor>
NotThatRPG: does this make sense? turtleware.eu/static/paste/f637d057a171863fc0e6c100285ee6fb7745317a-foo.lisp
* NotThatRPG
draws truth table...
Alfr has joined #commonlisp
Perflosopher has joined #commonlisp
tyson2` has joined #commonlisp
vassenn has joined #commonlisp
<NotThatRPG>
john_titor: I assume that the original author of type= wanted to avoid an unnecessary call to SUBTYPEP on the grounds that it might be expensive, but yes, I think your boolean function is correct.
tyson2 has quit [Ping timeout: 268 seconds]
tyson2` has quit [Remote host closed the connection]
jon_atack has joined #commonlisp
jonatack has quit [Read error: Connection reset by peer]
raemac has quit [Ping timeout: 240 seconds]
Gleefre has joined #commonlisp
Gleefre has quit [Remote host closed the connection]
<NotThatRPG>
Bike: It's modal logics of knowledge!
<NotThatRPG>
\box \neg P -> \box \neg (P & Q) for any Q
lucasta has quit [Remote host closed the connection]
<NotThatRPG>
\diamond \neg P & \diamond \neg Q -> \diamond \neg (P & Q) but NOT \box \neg (P & Q)
<Bike>
eck, it would be even more confusing with quantifiers
<NotThatRPG>
Yeah, when is IRC getting mathmode! ;-) Seriously, though, thinking about this as "knows" (\Box) or "believes" (\diamond) explains why the truth table is shaped as it is.
<NotThatRPG>
Anyway, I have pushed the MR, so now it's up to someone with the commit bit...
waleee has quit [Ping timeout: 240 seconds]
jonatack1 has joined #commonlisp
jon_atack has quit [Ping timeout: 260 seconds]
Brucio-61 has quit [Ping timeout: 260 seconds]
tyson2 has joined #commonlisp
Brucio-61 has joined #commonlisp
vassenn has quit [Quit: Leaving]
tyson2` has joined #commonlisp
tyson2 has quit [Ping timeout: 240 seconds]
Brucio-61 has quit [Ping timeout: 260 seconds]
cage has quit [Quit: rcirc on GNU Emacs 28.2]
euandreh has quit [Read error: Connection reset by peer]
<NotThatRPG>
Anyone know if CMUCL has normal compiler-macros? I'm finding that Alexandria's tests fail on CMUCL because (compiler-macro-function 'curry) returns NIL even though there is a define-compiler-macro form and when I evaluate it in the REPL it does not cause compiler-macro-function to be set.
markb1 has quit [Quit: Leaving]
Brucio-61 has joined #commonlisp
Cymew has joined #commonlisp
tyson2`` has joined #commonlisp
tyson2``` has joined #commonlisp
_cymew_ has quit [Ping timeout: 276 seconds]
tyson2` has quit [Ping timeout: 240 seconds]
tyson2`` has quit [Ping timeout: 240 seconds]
<NotThatRPG>
One more MR, and I think the Alexandria regression tests will all be fixed (ish -- a couple are XFAILs)
waleee has joined #commonlisp
<NotThatRPG>
oh... still an issue with ABCL...
kevingal has quit [Ping timeout: 248 seconds]
bjorkintosh has quit [Quit: Leaving]
waleee has quit [Ping timeout: 265 seconds]
waleee has joined #commonlisp
igemnace has quit [Remote host closed the connection]
Cymew has quit [Ping timeout: 268 seconds]
bjorkintosh has joined #commonlisp
bjorkintosh has joined #commonlisp
tyson2``` has quit [Ping timeout: 240 seconds]
waleee has quit [Ping timeout: 240 seconds]
tyson2 has joined #commonlisp
tyson2 has quit [Read error: Connection reset by peer]
Gleefre has joined #commonlisp
tyson2 has joined #commonlisp
tyson2` has joined #commonlisp
tyson2`` has joined #commonlisp
tyson2``` has joined #commonlisp
tyson2 has quit [Ping timeout: 276 seconds]
tyson2` has quit [Ping timeout: 240 seconds]
tyson2`` has quit [Ping timeout: 240 seconds]
tyson2``` has quit [Ping timeout: 268 seconds]
piethesailor has quit [Remote host closed the connection]
waleee has joined #commonlisp
waleee has quit [Ping timeout: 248 seconds]
akoana has joined #commonlisp
waleee has joined #commonlisp
shka has quit [Ping timeout: 268 seconds]
waleee has quit [Ping timeout: 248 seconds]
jonatack1 has quit [Quit: WeeChat 3.8]
jonatack has joined #commonlisp
waleee has joined #commonlisp
waleee has quit [Ping timeout: 265 seconds]
Gleefre has quit [Remote host closed the connection]
NotThatRPG has quit [Ping timeout: 268 seconds]
NotThatRPG_ has joined #commonlisp
NotThatRPG_ has quit [Ping timeout: 268 seconds]
waleee has joined #commonlisp
euandreh has joined #commonlisp
attila_lendvai has quit [Read error: Connection reset by peer]
attila_lendvai has joined #commonlisp
attila_lendvai has quit [Read error: Connection reset by peer]
attila_lendvai has joined #commonlisp
waleee has quit [Ping timeout: 240 seconds]
OlCe has quit [Remote host closed the connection]
nij- has joined #commonlisp
<nij->
Is there something like (asdf:load-path "/my/fav/project.asd")?
<nij->
Or must I add /my/fav to the search paths, and then #'asdf:load-system?
jonatack has quit [Ping timeout: 265 seconds]
david` has quit [Remote host closed the connection]
<Bike>
asdf generally wants you to use its thing for telling it where to find systems.
morganw has quit [Remote host closed the connection]
<nij->
:(
jonatack has joined #commonlisp
<nytpu>
nij-: shhhh it's a secret but but usually i put "(cl:require "asdf")" and "(cl:in-package #:asdf-user)" at the top of my .asd files, and afterwards you can do "(load "/path/to/project.asd")" and then use ASDF:LOAD-SYSTEM or QL:QUICKLOAD on that system as necessary
<nytpu>
or asdf::load-asd which should work outside registered directories but i think i've ran into issues before with it
lucasta has joined #commonlisp
<nij->
Why is it a secret? (Thanks, lemme try it now.)
<nij->
By the way, I did some stress test on bordeaux threads...
<nij->
It seems that only 90% of the threads do their jobs successfully: https://bpa.st/Q3VCO
<ixelp>
View paste Q3VCO
<nij->
I wonder why..
<hayley>
PUSH is not atomic.
<nytpu>
nij-: the ASDF devs and many random Lispers seem to be very insistant that you should never manually load .asd files and you can only ever load systems by dumping them in the search path
<nytpu>
which, no, i organize my projects in the filesystem how i like thank you
<nij->
hayley - but if I don't let the threads sleep at all, success rate is 100% so far
<hayley>
I'm not sure why that is, but you shouldn't expect either case to work.
<nij->
Hmm I can just asdf:defsystem, cl:load that file, and asdf:load-system! Thank you nytpu.
<nij->
I wonder why they suggest otherwise though. Eager to learn some reasons behind.
<nij->
hayley Is there a better way for me to check if all 10000 threads were actually doing well>
<nij->
?
<hayley>
Take a lock while updating shared state.
nij- has quit [Remote host closed the connection]
akoana has quit [Quit: leaving]
nij- has joined #commonlisp
<nij->
I let them write a line to a file. And then they work fine..
<nij->
However, it seems that my sbcl cannot ask my OS to create more than 5000 threads.
<nij->
I wonder why @@..
pve has quit [Quit: leaving]
<Alfr>
nij-, try the following for your lambda: (lambda () (let ((a *tmp*)) (sleep 3) (setf *tmp* (cons i a))))
<nij->
I haven't tried but I guess a will be fixed at the empty ().
<nij->
Lemme try now.
<nij->
Yep, as I guessed :)
<Alfr>
nij-, in other words what you consider succeeding may spectacularly fail if the os decides to run other things.
<nij->
The OS shouldn't know that it's a separate thread.
<nij->
Thread is internal to sbcl.
<Alfr>
nij-, I'd expect about a 1 element list.
<nij->
Alfr yes
<Alfr>
nij-, last I checked, sbcl uses os threads.