<pl>
hmmm.... pretty sure you can add/remove slots dynamically in CLOS
john__ has quit [Ping timeout: 268 seconds]
<pl>
can't do that for symbols, but that's what symbol-plist is for
selwyn has joined #commonlisp
makomo has quit [Ping timeout: 248 seconds]
random-nick has quit [Ping timeout: 272 seconds]
Guest92 has joined #commonlisp
<Guest92>
Hi all. I'm new to CL. Just a quick question, is there a go-to JSON encoding/decoding library I should be using? I'm playing around with REST APIs.
Guest92 is now known as cpu6502
asarch has joined #commonlisp
Fare has quit [Ping timeout: 258 seconds]
asarch has quit [Quit: Leaving]
Fare has joined #commonlisp
nij- has quit [Quit: Using Circe, the loveliest of all IRC clients]
<Josh_2>
jonathan for encoding and something else for decoding
<Josh_2>
jonathan and jsown
<cpu6502>
akater[m]: that's quite an exhaustive review! thanks.
<Josh_2>
altho I personally use jonathan for decoding when I am connecting to a known api
tyson2 has quit [Quit: ERC (IRC client for Emacs 27.2)]
cpu6502 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<akater[m]>
Consider the following general problem: starting with a list of keywords (“spec”) and a plist where all keywords are unique and are present in the spec, complete the plist to a plist which contains values for all keywords in the spec. Procedures that perform the completion generally come from independently developed libraries, often take into account key-value pairs found in he plist so far and often depend on dynamic environment. Of
<akater[m]>
course it could be any k-v map, not neccesarily plist.
<akater[m]>
Does this problem have a name? Something like “form filling” maybe?
<dieggsy>
akater: so you're saying something like spec - '(:key1 default-val1 :key2 default-val2 :key3 default-val3) plist - '(:key1 foo) -> result '(:key1 foo :key2 default-val2 :key3 default-val3) ?
<moon-child>
pl: well, sure--how fast do you expect symbol-plist is?
doyougnu has joined #commonlisp
<pl>
moon-child: depends on too many things to give proper baseline, but unless you go too high in numbers, you're going to get decentish performance
<akater[m]>
dieggsy: Spec is a list of keys. Maybe value types. But there hardly are “default values”, more like default procedures to get them (and usually they just ask user interactively)
<akater[m]>
One example is a completion of function name at point. Another is completion of incomplete connection spec to a spec containing usersame, host, key/password, optionally proxy. Starting combinations here may vary, many are reasonable, and it makes sense to complete differently depending on what we start with.
<akater[m]>
I just wonder if there's a name. I'm writing CLOS protocol for this and I mostly ask here because the problem seems general enough and dynamic enough to require CLOS powers significantly. Naive attempts to support multiple “backends” modularly seem to quickly turn into duplicated code and ad hoc solutions.
<akater[m]>
In the same time, lots of tasks seem to fall into this category. Resembles pattern matching but it's not quite that.
peterhil has quit [Ping timeout: 272 seconds]
prxq_ has joined #commonlisp
cpu6502 has joined #commonlisp
prxq has quit [Ping timeout: 248 seconds]
<beach>
Good morning everyone!
selwyn has quit [Read error: Connection reset by peer]
lad has joined #commonlisp
kuler has joined #commonlisp
blihp has quit [Remote host closed the connection]
heretical_crypte has quit [Ping timeout: 245 seconds]
alphapapa[m] has quit [Ping timeout: 240 seconds]
Mrtn[m] has quit [Ping timeout: 256 seconds]
happy-dude has quit [Ping timeout: 240 seconds]
dieggsy has quit [Ping timeout: 272 seconds]
hayley has quit [Ping timeout: 252 seconds]
luis` has quit [Ping timeout: 245 seconds]
akater[m] has quit [Ping timeout: 252 seconds]
etimmons has quit [Ping timeout: 276 seconds]
Gnuxie has quit [Ping timeout: 276 seconds]
loke[m] has quit [Ping timeout: 272 seconds]
rain3 has quit [*.net *.split]
khrbt_ has quit [*.net *.split]
dilated_dinosaur has quit [*.net *.split]
Alfr has quit [*.net *.split]
Inline has quit [*.net *.split]
lotuseater has quit [*.net *.split]
luna-is-here has quit [*.net *.split]
greyrat has quit [*.net *.split]
ski has quit [*.net *.split]
Vultyre has quit [*.net *.split]
mmk2410 has quit [*.net *.split]
eta has quit [*.net *.split]
bldr has quit [*.net *.split]
gwefnn has quit [*.net *.split]
Vultyre has joined #commonlisp
greyrat has joined #commonlisp
Inline has joined #commonlisp
khrbt_ has joined #commonlisp
mmk2410 has joined #commonlisp
rain3 has joined #commonlisp
eta has joined #commonlisp
bldr has joined #commonlisp
gwefnn has joined #commonlisp
ski has joined #commonlisp
luna-is-here has joined #commonlisp
lotuseater has joined #commonlisp
Alfr has joined #commonlisp
dilated_dinosaur has joined #commonlisp
icepic1984[m] has quit [Ping timeout: 245 seconds]
JooTvora[m] has quit [Ping timeout: 272 seconds]
Fare has quit [Ping timeout: 258 seconds]
dsk has quit [Remote host closed the connection]
drmeister has quit [*.net *.split]
jcowan has quit [*.net *.split]
aeth has quit [*.net *.split]
Lord_Nightmare has quit [*.net *.split]
lucerne has quit [*.net *.split]
theBlackDragon has quit [*.net *.split]
hugo has quit [*.net *.split]
katco has quit [Ping timeout: 256 seconds]
jcowan has joined #commonlisp
aeth has joined #commonlisp
drmeister has joined #commonlisp
lucerne has joined #commonlisp
Lord_Nightmare has joined #commonlisp
theBlackDragon has joined #commonlisp
hugo has joined #commonlisp
mariari has quit [*.net *.split]
Jach has quit [*.net *.split]
sterni has quit [*.net *.split]
mariari has joined #commonlisp
Jach has joined #commonlisp
sterni has joined #commonlisp
cromyr has quit [Quit: Client closed]
cpape` has quit [*.net *.split]
^[ has quit [*.net *.split]
jdz has quit [*.net *.split]
fishfinger_ has quit [*.net *.split]
kagevf has quit [*.net *.split]
commandoline_ has quit [*.net *.split]
gabc has quit [*.net *.split]
pok has quit [*.net *.split]
ane has quit [*.net *.split]
jemoka has quit [*.net *.split]
phoe has quit [*.net *.split]
|3b| has quit [*.net *.split]
GreaseMonkey has quit [*.net *.split]
cheers has quit [*.net *.split]
ane_ has joined #commonlisp
commandoline has joined #commonlisp
cpape`` has joined #commonlisp
greaser|q has joined #commonlisp
pok_ has joined #commonlisp
kagevf has joined #commonlisp
phoe has joined #commonlisp
gabc_ has joined #commonlisp
pok_ is now known as pok
cheers has joined #commonlisp
phoe has joined #commonlisp
phoe has quit [Changing host]
|3b| has joined #commonlisp
jemoka_ has joined #commonlisp
pok has quit [Changing host]
pok has joined #commonlisp
jdz has joined #commonlisp
knobo has quit [Ping timeout: 246 seconds]
fishfinger has joined #commonlisp
Fare has joined #commonlisp
Alfr has quit [Killed (lead.libera.chat (Nickname regained by services))]
Alfr has joined #commonlisp
JooTvora[m] has joined #commonlisp
akater[m] has joined #commonlisp
hayley has joined #commonlisp
icepic1984[m] has joined #commonlisp
Inline has quit [Quit: Leaving]
hayley has quit [Changing host]
hayley has joined #commonlisp
<contrapunctus>
Is there any way to get SLIME to display function/macro signatures in greater detail? e.g. for defclass I see just `(defclass name direct-superclasses direct-slots &rest options)`, whereas I'd like to see the slot and class options too 🤔️ (without going the CLHS route)
luis` has joined #commonlisp
<beach>
I think SLIME is just using the information provided by the implementation. So either you change the lambda list of the macro in the implementation, or else you make SLIME use some additional information.
katco has joined #commonlisp
ane_ is now known as ane
scymtym has quit [Ping timeout: 268 seconds]
pillton has joined #commonlisp
doyougnu has quit [Ping timeout: 268 seconds]
shka has joined #commonlisp
Cymew has joined #commonlisp
Gnuxie has joined #commonlisp
loke[m] has joined #commonlisp
alphapapa[m] has joined #commonlisp
Cymew has quit [Ping timeout: 240 seconds]
asarch has joined #commonlisp
etimmons has joined #commonlisp
Cymew has joined #commonlisp
heretical_crypte has joined #commonlisp
<susam>
Good morning, beach!
lisp123_ has joined #commonlisp
<susam>
Good morning, everyone!
Mrtn[m] has joined #commonlisp
<beach>
Hello susam.
lisp123 has quit [Ping timeout: 268 seconds]
lad has quit [Ping timeout: 268 seconds]
dieggsy has joined #commonlisp
john__ has joined #commonlisp
happy-dude has joined #commonlisp
Fare has quit [Ping timeout: 272 seconds]
psycomic has joined #commonlisp
pve has joined #commonlisp
michal has joined #commonlisp
<michal>
Hello
<michal>
Can I ask a question?
Lord_of_Life_ has joined #commonlisp
<beach>
Hello Michal.
<beach>
Of course. Go right ahead.
<michal>
Thanks Beach
<michal>
Is it possible to inherit all symbols of a package, not just the exported ones of that package?
Lord_of_Life has quit [Ping timeout: 268 seconds]
<michal>
So I don't need to refer to internal symbols with a "::"
Lord_of_Life_ is now known as Lord_of_Life
<beach>
It is possible to do it programmatically, but that's a really bad idea.
<beach>
Even referring to them with :: is a bad idea.
<beach>
Even USE-ing a package (other than the CL package) is a bad idea.
<beach>
A package exports precisely the symbols that are meant to be used by client packages. There is some assumption that those symbols won't change or do anything different in the future.
<beach>
But internal symbols are basically anything else, like the parameter x in a function. You don't want to use those in a client package.
<michal>
Thank you, I agree
<michal>
I am actually trying to write some test packages so the test package is sort of like the main package
<lisp123_>
Is it possible to use the same package name within the test package?
<beach>
In my experience, it is best to test your code using only exported functionality. Otherwise, you have to rewrite the tests whenever some implementation detail changes.
<michal>
I see, thank you
<michal>
I understand that perspective, perhaps I should try it that way.
asarch has quit [Quit: Leaving]
<rain3>
beach: for a few months I followed the advice "USE-ing a package (other than the CL package) is a bad idea." to the extreme . But then my defpackages definitions were very long, they would fill an entire screen and I would spend a lot of time specifying :import-from ... . I have come to the understanding that it is as bad as always using just :use
<beach>
rain3: I think that means that your packages contain more functionality than they should.
<hayley>
You could use package local nicknames as a compromise between typing no prefix with :use or typing all the package prefix. For example, while the name of one package I use is SICL-REGISTER-ARRANGEMENTS, I only type the prefix ARR: as a package local nickname was used.
<beach>
rain3: I tend to structure my code into "modules", where each module resides in a directory, has one ASDF system definition, and one package definition.
<hayley>
But yeah, it is also possible you are doing too much in a package/module.
<rain3>
ok . I'll continue observing , maybe I missed this
<michal>
Oh I see, thank you hayley. I saw package local nicknames but did not know what they were for.
<pve>
Michal: what kind of tests are you writing?
<michal>
On a related question, how many exported functions is "too much" for a package, because I am facing a similar issue to rain3 in that I have too many symbols in a package. Hence, I put them all into one package to avoid having to keep amending my export list. But at the same time, from a testing perspective, I wanted to test the 'submodules' if you may call them that - not the most elementary functions, but not the ultimate high level
<michal>
function either
<michal>
pve: I am using Parachute
<lisp123_>
I am curious to this question as well!
sterni has quit [Quit: WeeChat 2.9]
<beach>
Michal: You can't put a number on that. A module should ideally do one thing. Typically, it's the definition of some abstract data type. Then the exported symbols are the names of classes and generic functions of the protocol for that abstract data type.
<hayley>
I think the question is what you are testing; say, some exported functions, some internal data structure, a whole application, or so on.
sterni has joined #commonlisp
<hayley>
(loop for x being the external-symbols of (find-package 'netfarm) count t) ; ⇒ 106, so I can't really complain about fewer than 106 symbols.
<beach>
Michal: Modularity works basically the same in most programming languages. You split up your code into modules that are coherent in some way.
<michal>
I would like to test certain steps that make up an exported function for example.
<beach>
Michal: Then, the number of exported symbols should be small.
<pve>
Michal: ok, I didn't mean what framework you are using, but rather what you are testing, like hayley said
<hayley>
(loop for x being the external-symbols of (find-package 'clim) count t) ; ⇒ 1955, but I hear that's quite tame for a full GUI toolkit. I heard the Swift UI stuff goes into tens of thousands?
<michal>
Thank you Beach. What if my exported symbol had some complex logic behind it, and I want to test each part
<beach>
hayley: Also, CLIM was specified at a time when it seems the package system was under-used.
<beach>
Michal: Then in those few cases you use ::.
<michal>
Hello pve. I think it falls under a mix of unit testing vs. integration testing (I wonder where the boundary is)
<hayley>
It depends on the logic, but generally you write enough tests to cover as many paths as possible.
pranavats has left #commonlisp [#commonlisp]
<michal>
Thank you Beach.
<beach>
Michal: Using :: has the additional advantage that you immediately indicate to the person reading your code that there is something fishy going on. And that person is likely you in a few weeks.
<michal>
That I agree, at least in the main code. But for testing, does that hold true as well?
<beach>
Michal: Would you like to expose the code of your big package so that people can give you feedback?
<hayley>
I only use one internal symbol in perhaps all my tests, and it is just to help observe the "progress" of a running concurrent program.
<beach>
Michal: Again, testing is best done using only the external protocol. I strongly suspect your code has modularity issues.
john__ has quit [Ping timeout: 268 seconds]
pranavats has joined #commonlisp
<hayley>
Oh, I found another one, but it is just to get everything into a steady state before a benchmark. And, admittedly, it is pointless because unless I am modifying the code between tests, it should be in a stable state already.
<michal>
Thank you. Let me revisit and fix that. So to conclude, its a warning sign if one is having to test internal symbols?
Fare has joined #commonlisp
<hayley>
A few years ago I thought I just had one module, but then I rewrote it and kept refactoring, and I ended up with ten. Go figure.
<michal>
Thank you hayley, seeing that perspective gives me hope that I need to keep working on my code and not assume its correct at the moment
<beach>
Michal: Exceptionally, it can be useful, but then, just mark those situations clearly by using ::.
<hayley>
Generally, yes. But it is reasonable to check if internal invariants are held, for example.
<michal>
I will try to reduce the number of internal symbols in my testing. Something to think about.
<beach>
Michal: Again, you may want to expose your code on a past site for feedback.
<beach>
Michal: That could resolve some issues. We are kind of left guessing why you are having these difficulties.
sterni has quit [Quit: WeeChat 2.9]
sterni has joined #commonlisp
<michal>
One second
<michal>
Let me clean it up a bit.
scymtym has joined #commonlisp
<michal>
It may not be perfect, but here's some of the main code. It has one exported function 'generate-core-data' which takes a series of returns and calcualtes a bunch of statistics
<michal>
The rest of the file is the statistics calculations
<michal>
So I only wanted to expose 'generate-core-data' because that produces the 'master set of statistics', and not each of the individual statistic generating functions
<beach>
Michal: There is A LOT of code duplication in there. Maybe if you find the right commonalities, the modularity will be more obvious.
<beach>
The only difference between PORT-WORST-MOTH and BENCH-WORST-MONTH seems to be 1 or 2.
cjb has quit [Quit: rcirc on GNU Emacs 28.0.50]
<michal>
Thank you. That makes sense.
<beach>
Michal: Certainly, if you refactor this code in the obvious way, you won't have to test each individual function, because each such function would be a trivial wrapper around a single function, so only the common function needs to be tested.
<beach>
I don't even see any difference between PORT-FREQ-PERFORMANCE and BENCH-FREQ-PERFORMANCE.
<michal>
And would you put the common function in its own package?
<beach>
Oh, fourth and fifth.
<michal>
Yes, its like a spreadsheet of returns & calculations. Hence the column number is the common change
<beach>
I think you can think about that later when you figure out what the abstractions are.
<beach>
So why not do the obvious thing and pass the number as an argument?
<michal>
Yes, it seems obvious in retrospect.
<beach>
then FREQ-PERFORMANCE is a function that takes an additional argument, and PORT-FREQ-PERFORMANCE and BENCH-FREQ-PERFORMANCE would call that common function with 1 or 2.
<beach>
Once you do this, you will likely find other commonalities.
<beach>
Then, I think your abstractions should be more obvious.
<michal>
Okay, let me try.
<michal>
I still don't like the whole passing core-data everywhere, but given the complexities of some of the calculations (they depend on values up to a certain point in the series), some of it was unavoidable.
<beach>
Michal: This kind of code is almost impossible to maintain. If a change needs to be made, then it must be made in the same way in several places. That's a big no-no.
<michal>
Not unavoidable, sorry, but the complexity was unavoidable. But let me try at least with these simple wins.
<beach>
If you don't like passing core-data, use a (special) dynamic variable.
<beach>
I think this code can be condensed to a 10th of what it is.
<michal>
Thank you, perhaps that's why testing for it seemed laborious.
<beach>
I suspect that is the case, yes.
<michal>
Thanks.
<beach>
Michal: Simple thing: you compute start-row and end-row in every single function. Why not abstract that into a function that returns two values?
Fare has quit [Ping timeout: 240 seconds]
<beach>
Michal: Is Common Lisp your first programming language?
<michal>
I used Microsoft Excel before
<beach>
Ah, OK. That explains why you are not so used to creating abstractions.
<michal>
They introduced Lambda functions and that got me searching online
asarch has joined #commonlisp
<hayley>
Lines 117-151 look like they could be simplified into one function which takes a column index, and a function to apply to the column.
<beach>
Michal: It is almost a rule that, whenever you see some duplication, even if it has a slight variation, you should create an abstraction for it.
<pve>
Michal: If the code is working now, you might write a couple of tests for generate-core-data before you start refactoring the individual functions
pillton has quit [Quit: ERC (IRC client for Emacs 27.2)]
<michal>
Thank you, I will try to pick up the duplications and think of minimising them (including lines 117 - 151)
<beach>
Good luck. And feel free to expose your improvements.
<michal>
Pve, thank you that is a good idea.
<michal>
Thank you Beach, I may do that once I do a second version. At least my code is working now (well I think), so the light at the end of the tunnel is not too far.
<michal>
Time to clean it up.
<beach>
Sure. Good luck.
hendursa1 has joined #commonlisp
hendursaga has quit [Ping timeout: 244 seconds]
<beach>
This code creates an almost irresistible desire for me to refactor it.
lisp123_ has quit [Quit: Leaving...]
<beach>
Michal: I would also attempt to bundle up start-year, start-month, end-year, end-month into an object called, say, PERIOD.
<beach>
Or INTERVAL.
<michal>
I will have a think about that.
<michal>
By the way, if you can refactor it and release it as a library, you will basically cover the requirements of most investment funds for basic statistics
<michal>
I need to add portfolio and benchmark attribution, and I think that's about it in terms of what is required for performance measurement
<pve>
Michal: is some part of this difficult to do with excel? (not an excel expert)
<michal>
I just transcribed my excel formulae into Common Lisp, which partly would explain the way its written. The main complexity is that (a) the input data is a time series (dates, returns for those dates) and (b) many of the statistics rely upon all the statistics of every date upto that period. So one needs to store all the intermediate results
<michal>
I guess a mapping function may be of use here, I will see if that works. But its some relatively complex interdependencies (but always one way - at any point in time, one needs the data before it but not after it).
<michal>
For example, if you see the main core-data function - you can see how many let variables are defined in it - each one being used in subsequent ones
<michal>
So my solution was to keep all this data in a 'core-data' object, which gets passed in each time.
<pve>
Michal: are you saying you hade no previous programming experience, besides excel?
<michal>
I did a bit of Visual Basic
lisp-newbie has joined #commonlisp
<pve>
Michal: Mathematical background? I'm impressed that you recursively generate the core date. Not something a beginner would do, I'm guessing.
<pve>
*data
<michal>
Thanks Pve. I don't know, I was trying it for a while :)
<michal>
I have a bit of maths background but only high school
<michal>
I just replicated the formulas in my Excel sheet. Since they required all the prior rows, I stored this in 'core-data' and then kept adding to it
<michal>
I think I saw some basic example of recursion in the Lisp tutorials, so perhaps that's what guided me.
<rain3>
cool
<lisp-newbie>
Hi, I'm inside a macro trying to concatenate a string, and for some reason it compiles as a function. I think because the string is turned into a symbol instead of a string. I've tried doing this: (nth-value 2 (function-lambda-expression #'+)) replaceing the + for the string, with no success. Any ideas?
<pve>
Michal: cool, indeed
<lisp-newbie>
maybe (string xx), will try
<beach>
lisp-newbie: What you are saying makes no sense to me. Maybe show some code, what you expected, and what you got instead?
<beach>
lisp-newbie: A string can't "compile as a function".
<lisp-newbie>
beach will do one sec
<beach>
And strings don't get "turned into symbols" just like that.
<beach>
And then the example code seems unrelated to your string concatenation.
<lisp-newbie>
when I run it get this: Evaluation aborted for #<SB-PCL::NO-APPLICABLE-METHOD-ERROR {10040E3603}>
selwyn has joined #commonlisp
<lisp-newbie>
that's like a simplified version, I've broken up the larger macro into smaller peaces because going at it at once didn't work...
<beach>
There is no problem with the macro that I can see, except that the call to STRING seems superfluous. And the error must be generated by the call to DEFROUTE, and not from the macro expansion.
<ck_>
you're saying (defroute ("some-route" ..)) when you should have (defroute "some-route" ..)
<lisp-newbie>
beach it seems to me that the evaluator is ignoring the backquote and trying to evaluate the defroute function even though it has no comma
<beach>
lisp-newbie: That makes no sense.
voltron has joined #commonlisp
karlosz has joined #commonlisp
<lisp-newbie>
beach I addded the call to string because without it I was getting an error of trying to evaluate the string as a function saying it's not a function... one sec I will try something else
<beach>
lisp-newbie: Furthermore, your code has no trace of a string being turned into a symbol, nor of any FUNCTION-LAMBDA-LIST that you mentioned.
<lisp-newbie>
right, I changed that because it didn't work. one sec let me try something
<beach>
lisp-newbie: I don't recommend you introduce things arbitrarily without understanding what the problem is.
<beach>
lisp-newbie: I think ck_ may be onto something. I don't know the operator you are applying so I can't help with that.
<lisp-newbie>
beach I think it may be because in the repl where I evaluated it the function defroute was not available, so I'm trying to do it in the correct package...
<lisp-newbie>
beach ck_ thanks, there are two syntaxes, if I want to determine the HTTP method, then it's done with a parenthesis like this ("someroute" :method :POST)
<rain3>
lisp-newbie: first forget all about caveman , just reduce your thinking to the most basic unit of functionality you're trying to achieve. you said you want to obtain a string, or a symbol, so just focus on that first
<beach>
The existence or not of defroute can't possible influence the expansion of the macro.
<lisp-newbie>
beach that's what I thought... but then you said "And the error must be generated by the call to DEFROUTE, and not from the macro expansion."
<lisp-newbie>
what did you mean by that?
<beach>
That I don't see any thing in the macro that could have signaled such an error.
<beach>
Besides, you didn't show the details of the error message.
<beach>
Normally, it mentions the function in question.
<lisp-newbie>
beach oy vey, realized forgot the quote when calling macro expand
<lisp-newbie>
fixed it
<lisp-newbie>
sorry for the confusion
michal has quit [Ping timeout: 240 seconds]
<gin>
hunchentoot easy-acceptor listens on all interfaces by default. is there a way to restrict it to listen on 127.0.0.1 only?
wilfred has quit [Quit: Connection closed for inactivity]
<rain3>
maybe giving the key :address "127.0.0.1" )
Posterdati has quit [Read error: Connection reset by peer]
makomo has joined #commonlisp
amb007 has quit [Ping timeout: 248 seconds]
amb007 has joined #commonlisp
<lisp123>
Is log4cl the recommended logging library?
Posterdati has joined #commonlisp
attila_lendvai has joined #commonlisp
<antoszka>
Oh, I love the name, Inspector Clouseau — was one of my fav childhood comedies.
<beach>
Tim Moore came up with the name.
<antoszka>
Excellent.
nij- has joined #commonlisp
<beach>
I think I wrote most of the first version, but then scymtym rewrote it completely, and it is now a very nice program that can also be customized in lots of ways.
<beach>
For instance, I was able to customize it to recognize "ersatz" SICL objects during bootstrapping, so that I didn't have to stare at the host version of those objects.
<antoszka>
Nice.
<beach>
Of course, the customization ability is also what makes it highly modular. There is no difference between adding new kinds of objects to inspect and adding standard object types.
lisp-newbie has quit [Quit: This computer has gone to sleep]
lisp-newbie has joined #commonlisp
lisp-newbie has quit [Remote host closed the connection]
lisp-newbie has joined #commonlisp
kevingal has joined #commonlisp
kevingal has quit [Remote host closed the connection]
kakuhen has quit [Read error: Connection reset by peer]
<gin>
another hunchentoot question: is there a way to prevent the REPL from quitting when top-level is done? I want the REPL to stay alive as long as Hunchentoot is running.
Cymew has quit [Ping timeout: 268 seconds]
<lisp123>
gin: That is strange, can you share your code?
<lisp123>
Thanks gin, but do you know why REPL is quitting?
<lisp123>
It shouldn't
<gin>
lisp123: because the top-level exits
<lisp123>
Why is that
<lisp123>
What IDE are you using?
<gin>
lisp123: IDE?
<lisp123>
Are you using Emacs / Slime for example?
<gin>
lisp123: yes. but that is unrelated to my question. I want to keep the top-level running as long as hunchentoot is running.
<lisp123>
What happens if you do M-x slime-restart-inferior-lisp and then (ql:quickload :hunchentoot) and then the above code?
<lisp123>
It shouldn't exit
<gin>
lisp123: yes, no problem in that case. now put that code in foo.lisp and run sbcl --script foo.lisp < /dev/null and the program will die as soon as top-level quits without really waiting for hunchentoot to shutdown
<lisp123>
Ah I see (I was suspecting that too)
<flip214>
gin: add a (sleep most-positive-fixnum) at the end
<gin>
flip214: thanks
<lisp123>
Perhaps add a loop which takes in user input, and then exit the loop on a certain command
<flip214>
or have some loop that acts on unix signals - reloading the config, cleanly quitting, etc.
<gin>
lisp123: wouldn't that loop quit too immediately because the standard input is directed to /dev/null?
<gin>
loop for unix signals sounds like a good solution
<lisp123>
gin: Would it be possible just to load the file in Slime directly?
<lisp123>
That way you can modify it as you go about your day, while not shutting down the server
<lisp123>
Unless you are planning on making an executable
<gin>
lisp123: for dev, yes. for running it an unattended manner, I am trying to integrate it with ubuntu systemctl which redirects the standard input to /dev/null
<lisp123>
Understood, thanks
<lisp123>
Just check if the loop doesn't cause you any issues
<_death>
better to just sleep and not depend on such implementation details
random-nick has joined #commonlisp
gabc_ is now known as gabc
tyson2 has joined #commonlisp
<gin>
_death: is bt:all-threads considered to be implementation details?
<_death>
gin: I mean the details of what constitutes a "hunchentoot thread", and which one of them to wait on, and so on
<gin>
_death: understood. I like the simplicity of sleep solution too.
<lisp123>
How often do you like to use free variables in your code?
<lisp123>
I am finding I am using them more and more. For example, for print-object, I can create different versions, based on a global setting (which is a free variable in the print-object method)
<hayley>
You mean, special variables?
<lisp123>
I can see libraries doing similar things reasonably frequently, but it does seem a bit going away from a functinal style
voltron has quit [Remote host closed the connection]
<lisp123>
hayley - I'm not sure if its exactly the same
<hayley>
There is something like special variables in Haskell. Implicit parameters?
<lisp123>
a free variable is one that is not bound in the form and relies on functions called up higher (if my wording is correct), usually referring to global / special variables but not necessarily
<hayley>
Right.
<lisp123>
for example I could define -my-free-variable- within a LET
<lisp123>
and then any lets within that let, could refer to that -my-free-variable- --> so in this case, its not a special variable
<lisp123>
just a free one
<lisp123>
That way, I am not worried about other parts of the program changing its value
<_death>
gin: even better is not to quit once the function returns, i.e. not using --script.. instead you can use, say, --load
<gin>
_death: yes, tried sbcl --load too and it did not help since systemctl redirects stdin to /dev/null. So even with --load, sbcl quits as soon as it hits the last line of my top-level code.
<lisp123>
Color is a free variable within the inner let in this function - this is a trivial example, but I am frequently starting to use this paradigm for control flow // and other computations. Not sure if I am going down a dark path..
<_death>
gin: there's an old tool called detachtty (I use it on my server)
lisp-newbie has joined #commonlisp
derelict has joined #commonlisp
salvatore has joined #commonlisp
salvatore has quit [Remote host closed the connection]
<lisp123>
Is there an equivalent for boundp for lexical bindings?
<lisp123>
I guess I could use a combination of symbol-value & ignore-errors
<lisp123>
Wonder if there was another way
kuler has joined #commonlisp
<akater[m]>
lisp123: “If it were possible, the compiler would be very limited in the kinds of optimizations it could do.” — beach . The question seems to be popular.
<lisp123>
akater[m]: Is this in relation to boundp & lexical bindings?
<hayley>
The set of lexical bindings could be determined at compile time, but I don't see why you want it.
<lisp123>
symbol-value also *seems* to only work for global variables, I am investigating it further
<lisp123>
I am trying to create print-object, which will first read *print-method* and then determine which print configuration to use
<lisp123>
So I have added in a special declaration to make it work
<_death>
you need another special declaration at the point of reference
<beach>
lisp123: What _death said. You now have a lexical COLOR in BAR and a special one in FOO.
<mfiano>
This is why defvar/defparameter special declaration with conventional earmuffs is a good idea.
<lisp123>
Do I need (locally (declare (special color)) color) within bar?
<beach>
And your lack of earmuffs means you are violating the naming convention.
<lisp123>
beach: So looks like you guys solved my problem.
<lisp123>
Despite all the confusion I created
<lisp123>
My original question earlier was to get boundp to refer to lexical bindings
<lisp123>
But as the variables need to be special anyway, that question has disappeared
<beach>
You can't and you don't have to, because lexical variables are always bound.
<beach>
There is no way to create an unbound lexical variable.
<lisp123>
beach: Thanks yes, I realise that now (but not at the start of this conversation)
<lisp123>
_death: can you expand on "you need another special declaration at the point of reference"?
<_death>
lisp123: such use of specials is not usual.. often there are better ways to solve the actual problems
<lisp123>
_death: I am trying to customise print-object
<mfiano>
Yes. It seems like you are trying to make things hard on yourself intentionally.
igemnace has joined #commonlisp
<mfiano>
Learn about special variables and FORMAT in PCL then?
<lisp123>
If *print-method* is unbound, then do default printing, otherwise follow whichever print method is selected
<_death>
lisp123: expand in what way? seems you got it with the locally form, or you can declare it wherever else declarations are allowed
<lisp123>
_death: Okay, so my last example was fine?
<lisp123>
mfiano: This is for setting the defaults for printing classes
<mfiano>
I know
<lisp123>
via the defmethod print-object
<_death>
lisp123: if you're talking about your paste, you had a declaration at the point of binding (in FOO) but not at the point of refernece (in BAR).. so you'd also need (declare (special color)) in BAR
<lisp123>
Since I can't pass in a variable for *print-method*, it has to receive the value from somewhere
<lisp123>
_death: Thanks, I will do that
<lisp123>
(is there a particular reason why?)
<_death>
lisp123: but why do you need a "*print-method*" variable, and if you do need it, why not use defvar to say that it's special
<_death>
lisp123: the reason is that CL is lexical by default, and it's considered a good thing for a compiler to warn you when it sees a free variable
lisp-newbie has quit [Quit: This computer has gone to sleep]
<lisp123>
(just writing up an example)
silasfox has joined #commonlisp
lisp-newbie has joined #commonlisp
tyson2 has quit [Quit: ERC (IRC client for Emacs 27.2)]
<lisp123>
mfiano: sorry, I think the tabs is due to paredit perhaps
<lisp123>
_death: so the difference here vs. declaring *print-method* via a defvar, is that here *print-method* "loses" its value automatically once all the forms are evaluated, whereas with defvar, one would have to remember to reset it to whatever the default value is
<_death>
it's possible that you're trying to use print-object for something that it's not intended to be used for
<lisp123>
The main purpose of *print-method* is to later put in various cases (e.g. info, extra-info, debug, etc.) so that it prints with the level of detail required
<hayley>
This doesn't sound like a good use of PRINT-OBJECT.
<_death>
print-object is for printing objects concisely, for development/debugging purposes or for naive serialization when *print-readably* is true
<lisp123>
_death: Sometimes I want a detailed print object, sometimes I want a very basic one, so I wanted to add that customizablity
<hayley>
That said, there is print-pretty\ which is a special variable which customizes printing in a way.
* hayley
fails to appease Markdown yet again.
<beach>
lisp123: What does it mean that one has to remember to reset it?
<_death>
for more intensive printing, there's describe-object.. you can also have your own functions, and you can also make use the pretty printer
<mfiano>
lisp123: It seems you want to use a special variable for a _flag_ then, not the object to be printed.
<mfiano>
All of the logic related to printing can be contained within print-object or auxilliary functions
<hayley>
And you can use LET to temporarily bind a special variable, so there is no need for "resetting" or whatever.
<beach>
Yes, that's why I am asking.
<lisp123>
beach: say I have (defparameter *print-method* nil), then within a function I set it to 'debug. If I don't reset it back to nil, then future calls to print-object will refer to 'debug
<hayley>
Don't set it. Just re-bind it.
<beach>
lisp123: Don't set it then, bind it.
<mfiano>
You should read about how dynamic binding works
<lisp123>
Ah yes, that makes sense
<lisp123>
So you guys don't like this approach to custom printing?
<lisp123>
I though it was cool
<hayley>
I don't think it is a great use of PRINT-OBJECT, no.
<mfiano>
Alkso parewdit is not responsible for your misconfigured Emacs that doesnt convert tabs to spaces. You need to setq-default the right Emacs variable, that slipped my mind, but I remember beach knows
<mfiano>
Also*
<lisp-newbie>
hi, is there an inspect or describe equivalent that instead of printing will just return a string? or with the stream, how to turn it into a string in a variable?
<mfiano>
These are 2 unrelated questions
<mfiano>
FORMAT, and INTERN
<lisp123>
mfiano: Thanks, let me look at that. Was easier just to blame paredit ;)
<_death>
another issue with your print-object method is that it uses the readers, which may signal errors, e.g., when the slots are not bound.. it often makes sense to only print the slot values if they're bound, i.e. use slot-boundp and slot-value
<lisp-newbie>
hayley thanks
<hayley>
I would have to check the lambda list of DESCRIBE, but if it takes a stream parameter to write to, you are basically set.
<lisp123>
_death: thanks, that's a good pickup
<lisp-newbie>
hayley it does
<lisp-newbie>
thanks!
<lisp-newbie>
hayley, great! it works! thanks! :D
Jach has quit [Quit: Leaving.]
kulernil has joined #commonlisp
lisp-newbie has quit [Quit: This computer has gone to sleep]
kulernil has quit [Remote host closed the connection]
kulernil has joined #commonlisp
silasfox70 has joined #commonlisp
kuler has quit [Remote host closed the connection]
derelict has quit [Quit: WeeChat 3.2]
silasfox has quit [Ping timeout: 240 seconds]
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
tyson2 has joined #commonlisp
silasfox70 has quit [Quit: Connection closed]
Bike has joined #commonlisp
silasfox has joined #commonlisp
Qwnavery has quit [Ping timeout: 258 seconds]
Qwnavery has joined #commonlisp
kevingal has joined #commonlisp
jans1 has joined #commonlisp
jans has quit [Ping timeout: 268 seconds]
jans1 is now known as jans
lisp123 has quit [Remote host closed the connection]
lisp123 has joined #commonlisp
tyson2 has quit [Quit: ERC (IRC client for Emacs 27.2)]
^[ has joined #commonlisp
Inline has joined #commonlisp
michal has quit [Ping timeout: 245 seconds]
lisp123 has quit [Ping timeout: 248 seconds]
hhdave has quit [Ping timeout: 240 seconds]
Fare has joined #commonlisp
voltron has quit [Remote host closed the connection]
lisp-newbie has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
nij- has quit [Quit: Using Circe, the loveliest of all IRC clients]
michal has joined #commonlisp
lisp123 has joined #commonlisp
amk has quit [Ping timeout: 268 seconds]
amk has joined #commonlisp
lad has joined #commonlisp
michal has quit [Ping timeout: 240 seconds]
lisp123 has quit [Ping timeout: 268 seconds]
amk has quit [Ping timeout: 268 seconds]
amk has joined #commonlisp
Alfr has quit [Quit: Leaving]
Alfr has joined #commonlisp
ggoes has quit [Ping timeout: 268 seconds]
ggoes has joined #commonlisp
attila_lendvai has quit [Ping timeout: 268 seconds]
kevingal has quit [Remote host closed the connection]
doyougnu has joined #commonlisp
kevingal has joined #commonlisp
kevingal has quit [Remote host closed the connection]
<lisp-newbie>
hi, if I have a list of key value pairs, and I have an existing object, how can I set every slot for which the key is a slot name?
Qwnavery has quit [Quit: WeeChat 3.2]
<lisp-newbie>
without getting an unbound-slot error
<beach>
lisp-newbie: You can handle the error, or use the MOP.
<_death>
slot-exists-p and (setf slot-value)
<lisp-newbie>
beach _death thanks
<beach>
Oh, right, no MOP needed.
taiju has quit [Ping timeout: 248 seconds]
taiju has joined #commonlisp
<lisp-newbie>
_death beach thanks I also found (describe 'slot-boundp)
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
michal has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
lisp-newbie has quit [Quit: This computer has gone to sleep]
michal has quit [Ping timeout: 248 seconds]
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
derelict has joined #commonlisp
cosimone has joined #commonlisp
silasfox has quit [Ping timeout: 240 seconds]
Devon has joined #commonlisp
Devon is now known as Devon7
Devon7 is now known as Devon
silasfox has joined #commonlisp
selwyn has quit [Read error: Connection reset by peer]
lisp123 has joined #commonlisp
michal has joined #commonlisp
Fare has quit [Ping timeout: 240 seconds]
silasfox has quit [Ping timeout: 240 seconds]
silasfox has joined #commonlisp
Cymew has quit [Ping timeout: 240 seconds]
michal has left #commonlisp [ERC (IRC client for Emacs 27.1)]
lisp-newbie has joined #commonlisp
amb007 has quit [Ping timeout: 248 seconds]
amb007 has joined #commonlisp
Lycurgus has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
Skyfire has quit [Quit: WeeChat 3.2]
amb007 has quit [Read error: Connection reset by peer]
<beach>
Qwnavery: Common Lisp evaluates a form only once by default.
<Qwnavery>
beach: ?
Fare has joined #commonlisp
<beach>
Qwnavery: Some other formalisms, like the lambda calculus will continue until a normal form is reached. Not so with Common Lisp.
<mfiano>
Qwnavery: I would not use SETQ. Use the generalized SETF instead
<mfiano>
Qwnavery: Also, you probably don't want to use APPEND. Most uses of it is a performance trap, including this one.
<beach>
In your code, the variable I is just a list of things.
<Qwnavery>
yes
<Qwnavery>
I tried using let
<beach>
There is nothing wrong with LET.
<Qwnavery>
All I'm trying to do is try and use homoiconicity to define an expanding power function that returns a lambda function of that nth multiplication
<beach>
Qwnavery: Do you want your function to generate a form, i.e., a list with * in the CAR, or do you want it to generate a function?
<mfiano>
It's unclear if you want to return a closure or generate code
<beach>
Qwnavery: There is no such thing as a "lambda function". There are lambda expressions and just functions. Functions are sometimes anonymous.
<Qwnavery>
ij
<Qwnavery>
ok
<beach>
The problem here is that, although you return a function, its body is just a variable that contains a form that is not being evaluated. You should generate the function instead of the form.
<Qwnavery>
I have the (lambda (x) i) returning because I want it to generate an anonymous function which can be called as (* x x... {n times})
<Qwnavery>
erm, is there a way to turn a list like '(* x x) into a function?
<random-nick>
(lambda (x) i) is just a lambda which always returns i
<random-nick>
(the list)
<Bike>
(defun power (n) (compile nil `(lambda (x) (* ,@(make-list n :initial-element x))))) (funcall (power 2) 2) => 4
<Qwnavery>
random nick: yes, i is (* x x) so it expands to (lambda (x) (* x x))
<Bike>
it doesn't "expand". why would it expand? "i" is just a variable.
<random-nick>
it doesn't expand
lisp-newbie has quit [Quit: This computer has gone to sleep]
<Qwnavery>
like, evaluates to
<random-nick>
the i in the lambda expression isn't replaced by the value of i
<beach>
But it is not evaluated.
<Bike>
you are confused about how evaluation works.
<Qwnavery>
what word do I use then wth
<beach>
Qwnavery: Because Common Lisp evaluates only once, so the variable i is evaluated to a list.
<Bike>
the "i" is evaluated in that its value is read.
<random-nick>
instead, the produced lambda object contains a reference to the value of i
<Bike>
that value is not evaluated again.
<Qwnavery>
I don't know how to describe it, i is a pointer to the list in memory that is (* x x) ???
<Bike>
you are overthinking it. listen. if you write (lambda () x), you get a function that reads the value of the variable x.
<beach>
Yes, and that list is just that, a list.
<Bike>
It does not then evaluate the value read.
<Qwnavery>
I get it.
<random-nick>
the construction of the lambda object doesn't read i at all
<Qwnavery>
Thanks Bike that makes sense
<beach>
Qwnavery: Try (defun power (n) (lambda (x) (apply #'* (make-list n :initial-element x))))
<Bike>
The definition of POWER i gave does what you want, i think. you can see that the form has to be explicitly made into a function by COMPILE. EVAL could also be used
<akater[m]>
Qwnavery: It's not about evaluation rules for i, it's about evaluation rules for lambda. lambda is a macro. It does not evaluate its arguments.
<Qwnavery>
akater[m]: bear with me, I don't understand macros quite yet.
<Bike>
macros aren't really related here.
<Bike>
this would work the same if #'(lambda ...) had been used, and in that form no macroexpansion is involved.
<Qwnavery>
Bike: Your defintion of POWER is very elegant.
<lotuseater>
oh a highlight on my nick :)
<Qwnavery>
Thank you beach, Bike, random-nick, akater[m]
<Qwnavery>
oop and mfiano
<Qwnavery>
lotuseater: don't look >_< it'll hurt your eyes.
<Qwnavery>
ok I'm going to sleep now that it's out of my head 0_0
<lotuseater>
i was in the kitchen
<mfiano>
Qwnavery: I mention this multiple times per day recently, but here it is again if you haven't seen it: Read Practical Common Lisp for free online. Some of your misconceptions can be solved by reading it.
<lotuseater>
yes you should
<Qwnavery>
mfiano: I tried at one stage
<Qwnavery>
attention span very short.
<mfiano>
Well fumbling in the dark is no way to learn. You need a gentle walkthrough of the language, which that is.
<mfiano>
Read little bits at a time, and take notes if you need to
<Qwnavery>
ok. sorry for being a nusiance
Qwnavery has quit [Quit: WeeChat 3.2]
<lotuseater>
Qwnavery already know that keeping an eye to details is important. :)
<mfiano>
You're not. I just want to see people succeed rather than get a wrong impression of Lisp
<mfiano>
heh
<lotuseater>
he's on a good way, I wrote with him a bunch in query the last days :)
<akater[m]>
Bike: > macros aren't really related here. — the person does not get evaluation rules (evaluation order, in particular). Macros are related in the sense they have non-standard evaluation rules.
<Bike>
we were already talking about evaluation rules. i don't see the point of bringing up macros when they are not actually involved.
<mfiano>
Bike is right. This has nothing at all to do with macros. The misunderstanding was at a much lower level.
lisp123 has quit [Remote host closed the connection]
<contrapunctus>
I happened to be defining a class named `quote` in a package that has `(:use :cl)`, which resulted in a package lock violation error. I imagine I could either change the class name, or change the `:use` to `:import-from` and specify the exact symbols I'm using (`quote` is not one of them...yet)...but is there any other alternative?
<mfiano>
add (:shadow #:quote) after :use
<mfiano>
but that might have disastrous consequences :)
<contrapunctus>
._.
<Xach>
mfiano: why?
char has joined #commonlisp
<mfiano>
I suppose it would not if you always use the reader macro. Such a common operator is all I mean
<Xach>
ah
<contrapunctus>
Thanks, I'm changing the class name ^^
<moon-child>
'quotation'?
notzmv has quit [Ping timeout: 248 seconds]
<mfiano>
'|'|
<moon-child>
thanks, I hate it
ec has joined #commonlisp
ec is now known as tl
<contrapunctus>
moon-child: indeed
<contrapunctus>
mfiano: what's that?
<mfiano>
That is a the symbol '
<mfiano>
s/a//
tl has quit [Client Quit]
<mfiano>
quoted
ec has joined #commonlisp
<mfiano>
so (defclass |'| ...)
<contrapunctus>
wat
<contrapunctus>
What is |? Never saw that before
<lotuseater>
contrapunctus: '|The pipes make symbols, I swear!|
silasfox has quit [Ping timeout: 245 seconds]
IPmonger has joined #commonlisp
IPmonger has quit [Remote host closed the connection]
<mfiano>
Xach: Can you remove my feed from Planet Lisp?
<contrapunctus>
mfiano: thanks, TIL 🤯️
hhdave has joined #commonlisp
<random-nick>
so why is that defined as an escape character
<random-nick>
instead of as a reader macro
<random-nick>
oh, so you could write it in the middle of a symbol
jfrent has left #commonlisp [WeeChat 3.1]
<lisp123_>
Is there a way for :after methods to have access to the bindings in the main method (CLOS query)?
<mfiano>
Use special variables or an around method instead.
<lisp123_>
mfiano: Thanks, will try around
ec has quit [Ping timeout: 244 seconds]
silasfox has joined #commonlisp
selwyn has joined #commonlisp
Danishman has joined #commonlisp
ec has joined #commonlisp
john__ has joined #commonlisp
john__ is now known as gaqwas
ec has quit [Remote host closed the connection]
ec has joined #commonlisp
retropikzel has joined #commonlisp
nij- has joined #commonlisp
amb007 has quit [Ping timeout: 240 seconds]
amb007 has joined #commonlisp
<lotuseater>
beach: Do you maybe know if drmeister plans for this year to give an updated talk about CLASP and the biomolecular metaprogramming? The first one was 2015, then 2018 and now it's 2021. :)
<Bike>
he has been busy doing biomolecular metaprogramming. i don't know if he's planning on a talk that isn't to a government agency with money
<Bike>
i might be able to answer particular questions
<lotuseater>
it's so awesome
<lotuseater>
Bike: cool you are able to understand how it works? :)
<Bike>
i am literally working on clasp right now
<lotuseater>
wow
<Bike>
if you mean how the chemistry works, i'm only a little familiar, though
<lotuseater>
it would be nice to understand these things, but I'm not good
<lotuseater>
so for the next pandemic CLASP generates us a working vaccine :)
greaser|q has joined #commonlisp
greaser|q has quit [Changing host]
greaser|q is now known as GreaseMonkey
<lotuseater>
so the CLASP compiler generates LLVM code, right?
<Bike>
LLVM-IR, yes.
tyson2 has joined #commonlisp
<pjb>
lotuseater: clasp, or nvidia.
psycomic has quit [Quit: Leaving]
ec has quit [Ping timeout: 244 seconds]
<lotuseater>
nice
<lotuseater>
I once tried to install on my NixOS, but it compiled over 30min and then I stopped it.
lisp123_ has quit [Remote host closed the connection]
<Bike>
it's pretty big. compilation times are way down from what they used to be, at least.
voltron has joined #commonlisp
<lotuseater>
oki :)
lisp123 has joined #commonlisp
<Bike>
llvm is not especially fast, and we are throwing hundreds of files at it.
<pjb>
contrapunctus: after shadow quote, you can both defmacro quote and defclass quote, so you can still write (make-instance (quote quote))
lisp123 has quit [Remote host closed the connection]
<pjb>
but all the functions and all the macros and all the reader macros that have been defined outside of your package would still work, since they'd already refer cl:quote, not your-package::quote.
<pjb>
the macro would only be a convenience so that you can keep using (quote x) in your package.
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
rain3 has quit [Remote host closed the connection]
cosimone has quit [Ping timeout: 245 seconds]
* lotuseater
realized yesterday that symbol-macros want proper list forms
<mfiano>
They do not need to be proper lists
voltron has quit [Remote host closed the connection]
<lotuseater>
i mean lists in general
amb007 has quit [Read error: Connection reset by peer]
<mfiano>
Not sure what you mean. They evaluate to what you give them
<mfiano>
or rather expand
<lotuseater>
yes
<lotuseater>
i had (define-symbol-macro N 17) but that's better as parameter
<mfiano>
More like a constant
<lotuseater>
or that
<mfiano>
I despise global symbol macros.
<mfiano>
There is no convention for their naming and it can be rather confusing
<lotuseater>
yes, I actually just use symbol-macrolet
<mfiano>
They are useful for some things, like deflex iirc
<aeth>
seems like the main thing they're for is ultra-niche hacks
<lotuseater>
saw sometime global symbol macros are named with % by convention
<aeth>
perhaps if you need to implement another language in CL
<aeth>
symbol-macrolet, however, is incredibly useful
ec has joined #commonlisp
<lotuseater>
aeth: oh yes :)
<aeth>
lets you extend the with-accessors style pattern to all sorts of things, e.g. array elements
<aeth>
this makes up for array access syntax being fairly awkward in Lisps vs in "normal" syntax languages
<mfiano>
symbol-macrolet is useful, however they have to be used with care in performance critical code
lisp123_ has joined #commonlisp
<mfiano>
It is too easy to ignore their expansion and treat the code as lexivars when read by a human
<aeth>
Yes. I'm assuming that they're only used for things that are compiler-inlinable, mainly struct accessors and array accessors.
<mfiano>
Which could be re-evaluating expensive (or not so expensive but tight-looped) things
<aeth>
Then it's on the implementation, not on the user.
<aeth>
Avoid CLOS generic accessors.
<aeth>
(in more elaborate symbol-macrolets, anyway... I do use WITH-ACCESSORS for simple things)
<lotuseater>
aeth: sometimes i did eg one arr[s] for (aref arr s)
<lotuseater>
or also with this .foo syntax
<aeth>
I sometimes use . to decompose arrays with symbol-macrolet since it's available... but I make it look more like the dot-accessor-notation of "normal" languages
<aeth>
e.g. foo.x foo.y foo.z
<aeth>
I find that that is, to me at least, clearer
<mfiano>
How Algol of you
amb007 has quit [Ping timeout: 240 seconds]
<aeth>
Especailly since it's a macrolet
<aeth>
*Especially
lisp123 has quit [Ping timeout: 240 seconds]
lisp-newbie has joined #commonlisp
amb007 has joined #commonlisp
<lotuseater>
algolholic?
<lotuseater>
"gosh, that looks like fortran"
<aeth>
If you've ever used almost any other programming language, an internal . within the symbol-macrolet will be immediately obvious. That is, decompose foo into foo.x, foo.y, and foo.z and it's clear that it's a symbol-macrolet related to foo, rather than fresh lexical bindings of local variables like foo-x, foo-y, and foo-z or x, y, and z
<aeth>
idk if anyone else uses this convention, though
<mfiano>
Add ":type (vector fixnum)" in there, and a corresponding deftype perhaps, to maybe get a bit more performance and have named accessor functions AND array indexing
<mfiano>
However, because types are mostly structural and not nominal, you no longer have a unique type to dispatch on with method specialization.
<mfiano>
Actually, I'm not sure how that even works. I could be wrong there. (runs some tests)
<pjb>
Just use quaternions for 3d or 4d points, and octonion up to 8d.
<pjb>
We should remmeber to add them to CL…
<pjb>
mfiano: correct, but there could be a branding mechanism. In Modula-3, we can define a type to be equal to another, then it's just a new name, or a type to be like another type but a new brand, then they're similar, but values of one type are not compatible with values of the other type.
khrbt_ is now known as khrbt
<pjb>
in lisp this branding would have to occur at run-time, but it'd be possible. It would just mean that (some) CL operations are really hidden generic functions.
<mfiano>
Oh silly me. I'm attempting to define it in the package I was currently working in, and of course it shadows CL:VECTOR
<White_Flame>
the true bug was the friends we made along the way
<pjb>
mfiano: cl:vector in that case.
<mfiano>
Right
<mfiano>
So I was correct. a struct with a type of vector or list no longer has a user-defined type of the name of the struct
<mfiano>
So you cannot dispatch on it in that case
<White_Flame>
how would the type be determined, given any given vector object?
<mfiano>
I have used (:type (vector single-float)) and (deftype name-of-struct () (simple-array single-float (3)) in my codes a long time ago to greatly speed up access
<mfiano>
While still allowing named access (in addition to aref)
<White_Flame>
sure, but that's not saying that some vector is of type POINT struct that you've defined
azimut has joined #commonlisp
<mfiano>
Sure
<mfiano>
It's an alias to mostly allow for concise ftype declarations
<mfiano>
The speed improvement is the use of an array over inlined struct field functions. There is (or was) a large difference
<mfiano>
This was many years ago. I have no idea if this produces a hairy data vector these days or not (on SBCL)
azimut_ has quit [Ping timeout: 244 seconds]
* mfiano
used to (foolishly) use structs _everywhere_ and coded Lisp more like C than I should be admitting.
notzmv has joined #commonlisp
sander has quit [Ping timeout: 256 seconds]
<White_Flame>
once I started doing a lot more heterogeneous language programming, as well as distributed systems, I ended up doing far fewer classes and just used simpler native data structures
hendursa1 has quit [Quit: hendursa1]
hendursaga has joined #commonlisp
<lotuseater>
mfiano: so good it's now different :)
<mfiano>
Yes, I value good protocol architecture over performance any day. Preferably one that allows for additive programming.
sander has joined #commonlisp
ec has quit [Ping timeout: 244 seconds]
<mfiano>
By additive, I mean adding features with minimal if any changes to existing codes.
<mfiano>
As well as interactive coding.
<mfiano>
Structs are not very good at that at all :)
ec has joined #commonlisp
cage has quit [Quit: rcirc on GNU Emacs 27.1]
<lotuseater>
how is the slot option :read-only translated to a slot in a clos class? just with the :READER option?
<mfiano>
Do you mean :read-only for struct slots?
<pjb>
lotuseater: yes.
<lotuseater>
yes i meant that
<mfiano>
By default 2 functions are defined for accessing a slot. Their names are FOO and (SETF FOO). :read-only prevents the latter from being defined.
<mfiano>
Assuming an empty conc-name that is
<lotuseater>
ok
<pjb>
well, for defstruct it's not specified how the accessors are implemented.
<pjb>
The writer could just be an entry in a table used by setf.
<lotuseater>
i realized a short time ago a defstruct takes multiple :constructor declarations
<mfiano>
Yes
<pjb>
(funcall '(setf foo) new-value foo-structure) is not conforming.
lisp-newbie has quit [Quit: This computer has gone to sleep]
<pjb>
lotuseater: which with boa constructors or with &aux let you do some funny stuff.
<lotuseater>
oh hm
<lotuseater>
so much possibilities
<pjb>
(defstruct (rect (:constructor rect (w h)) (:constructor square (s &aux (w s) (h s)))) w h) (square 3) #| --> #S(rect :w 3 :h 3) |#
nij- has left #commonlisp [#commonlisp]
<lotuseater>
ahh, useful
<mfiano>
I usually prefer external constructor (regulat) functions that call an internal struct constructor.
<mfiano>
But Lisp is flexible in every way
silasfox has quit [Ping timeout: 240 seconds]
waleee has quit [Ping timeout: 256 seconds]
waleee has joined #commonlisp
cuz has joined #commonlisp
Devon has quit [Ping timeout: 240 seconds]
dra has joined #commonlisp
lisp123_ has quit [Remote host closed the connection]
lisp123 has joined #commonlisp
ec has quit [Ping timeout: 244 seconds]
lisp123 has quit [Ping timeout: 245 seconds]
Inline has quit [Ping timeout: 245 seconds]
amb007 has quit [Read error: Connection reset by peer]
Inline has joined #commonlisp
amb007 has joined #commonlisp
MetaYan has quit [Ping timeout: 248 seconds]
MetaYan has joined #commonlisp
ec has joined #commonlisp
Danishman has quit [Quit: Leaving]
lisp123 has joined #commonlisp
PinealGlandOptic has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
cuz has quit [Remote host closed the connection]
amb007 has quit [Ping timeout: 240 seconds]
amb007 has joined #commonlisp
shka has quit [Ping timeout: 245 seconds]
Fare has quit [Ping timeout: 240 seconds]
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
ec has quit [Ping timeout: 244 seconds]
ec has joined #commonlisp
kulernil has quit [Remote host closed the connection]
<char>
What do you think of the opinion that throwing exceptions will go the way of goto
<hayley>
It won't.
<char>
care to elaborate?
<hayley>
"No." But goto didn't exactly go the way of goto, merely it got dynamic extent. The same can be said for exceptions^Wconditions.
<hayley>
And, in my opinion, any other option for condition handling makes the decision on what conditions can be recovered from too early, and/or shifts the conceptual "blame" to the handler when looking at a debugger.
cjb has joined #commonlisp
<jasom>
I really like the ability to run a condition handler before unwinding the stack. It's so obviously better that I don't understand why so few other languages have adopted it.
<char>
jasom: I really like that feature too.
<char>
another time it makes sense if for a long running function like a server?
ec has joined #commonlisp
<mfiano>
Note that some attempts to get rid exceptions, such as Rust's exhaustive pattern matching, are much more computationally expensive.
<moon-child>
the overhead
<moon-child>
is unlikely to be _very_ great in either case
<hayley>
Using monads for error handling also means you have to choose if (and how) results are wrapped, or if the thread should crash instead.
<moon-child>
imo, both rust-style error handling and condition-style error handling are prone to confusion over who is responsible for an error, and there is not really a semantic-level solution for that
<mfiano>
*
<mfiano>
err ^
<hayley>
So, now, for example, they are working on introducing constructors which can fail allocation, as currently threads crash if they can't allocate. Though what I recall might be out of date.
<mfiano>
Rust is trying to solve a lot of design mistakes, both in-language, and community conventions.
<moon-child>
my understanding is that haskell (exceptions are for exceptional behaviour; otherwise, errors are generally prevented by construction) style works well, but I have not used haskell in any serious capacity
<mfiano>
Such as freeing large heap objects being too slow, so they spawn a thread to do it in the background. Only to have the borrow-checker bite them harder much later (if it can even catch all the threading nonsense)
<hayley>
haha gencgc goes brr
<mfiano>
Oh yeah, and the most hilarious thing that is catching on in the Rust community as of late, is combating the large compile times by making more use of dynamic dispatch. I find that funny as hell, I don't know why.
<moon-child>
oh myy
Fare has quit [Ping timeout: 240 seconds]
pranavats has left #commonlisp [#commonlisp]
pranavats has joined #commonlisp
selwyn has quit [Read error: Connection reset by peer]
<pjb>
char: signaling condition is a kind of come-from, not go-to.
<char>
pjb: I know it isn't the same, but some people compare it to goto as a not-so-great software engineering practice.
<pjb>
gotos are not so bad. What's bad is the global scope of variables, and not having a clear view of the data flow going thru them. When all the modules access all the global variables, you have a big mess.
<mfiano>
tagbody/go is very useful for efficient state machines
<hayley>
Right, I recall someone tried to generate Rust code from a DFA and got stuck with no goto. So there may be a chance that Lisp code generation and goto lead to another fastest regex engine.
<pjb>
That said, good night!
ec has quit [Ping timeout: 244 seconds]
blihp has joined #commonlisp
<hayley>
"Gotos aren't damnable to begin with. If you aren't smart enough to distinguish what's bad about some gotos from all gotos, goto hell." — Erik Naggum
amb007 has quit [Ping timeout: 240 seconds]
dra has quit [Remote host closed the connection]
karlosz has quit [Ping timeout: 245 seconds]
kulernil has quit [Remote host closed the connection]
kulernil has joined #commonlisp
IPmonger has joined #commonlisp
IPmonger has quit [Remote host closed the connection]
ec has joined #commonlisp
pillton has joined #commonlisp
Josh_2 has quit [Quit: ERC (IRC client for Emacs 27.1)]