<beach>
hexology: And there is no such thing as "a lambda". There are "lambda expressions" that, when evaluated, turn into "functions". What other languages call "a lambda" is just "a function", possibly anonymous, in Common Lisp.
<lad>
Hi. I'm playing around with sb-ext:seed-random-state... for deterministic randomness. I noticed something odd, wondering if anyone has a clue? Pasting the example I find odd: http://pastie.org/p/2aO0mxdvxWMm65ciNIoCMi
<beach>
lad: What is nshuffle?
<lad>
beach, sorry let me add it
<asarch>
jeosol, what is 'paredit'?
<hayley>
Well, if nshuffle is destructive, you are lucky the second form doesn't summon nasal demons.
<beach>
That's what I am thinking.
<beach>
asarch: An Emacs mode that keeps parentheses balanced.
<hayley>
But the third would perform the same permutation with different elements if you do not reset FOO between runs.
<lad>
beach, i guess rotatef is destructive
<beach>
It is.
<beach>
lad: I am not sure what is going on, but I can tell you that you are modifying literal data, and then anything can happen.
dsk has joined #commonlisp
kuler has quit [Remote host closed the connection]
<lad>
beach, okay. yeah, that just seemed weird because it's the same list. i don't understand exactly what's going on either. I'm sort of after generating random sequences that I can recall via seed. Guess i need to think more about it
<lad>
beach, thanks for taking a look
<White_Flame>
a simple copy-list might get you what you want
<lad>
White_Flame, hi. hmm using copy-list seems to have the behavior
Qwnavery has joined #commonlisp
<lad>
White_Flame, wait, let me double check. may have spoke too soon
<beach>
lad: You could trace nshuffle to get an idea of what is going on.
pillton has quit [Quit: ERC (IRC client for Emacs 27.2)]
<lad>
White_Flame, that seemed to work :)
srhm has quit [Quit: Konversation terminated!]
srhm has joined #commonlisp
<White_Flame>
you need to (copy-list (car foo)), as copying foo itself would still keep the same EQ contents
<lad>
White_Flame, interesting, I took the approach of doing copy-list in nshuffle
<White_Flame>
ok, but now it's not "n" shuffle anymore ;)
<White_Flame>
(assuming you meant it to indicate it's desctructive)
<lad>
White_Flame, true... well i copied it off stack overflow and hadn't questioned the "n" in the name. is that a convention btw?
<White_Flame>
yes, like REVERSE vs NREVERSE
<lad>
White_Flame, cool, okay.
<lad>
White_Flame, so i wonder why copy-list works here vs a dynamic variable
<White_Flame>
it makes a new list
<White_Flame>
the variable holds a literal object, which is basically the list that came out of READing the source code, and retains its identity
<White_Flame>
I mean, if you (defvar *foo* '(1 2 3)), (defun buh (x) (incf (car x))), and (buh *foo*), that list will hold (2 2 3), then (3 2 3), etc
<White_Flame>
where that list is stored is kinda irrelevant
<White_Flame>
(let ((foo '(1 2 3))) (buh foo) (buh foo) foo) would perform the same destructive modification on the same list
Oladon has joined #commonlisp
<White_Flame>
however, since the equivalent of the source code is being modified there, the next time you run it it could still retain those changed values instead of starting from (1 2 3) again. Or anything else, as it's undefined behavior to change that
<lad>
White_Flame, okay, I kind of get it that the var is always being changed hence varying results ok
<White_Flame>
the var itself is not being changed; the value it holds however is being mutated
<White_Flame>
the var still points to the exact same cons/list object
<White_Flame>
the slots within the list being passed to nshuffle are being changed around, in the exact same list structure
<lad>
White_Flame, got it, the destructive nshfullle is always changing in the var's value. Then when copy-list is used, it's a creating local variable, new list that based on the dynvar. thx for help explaining
<White_Flame>
not a local variable, just a new value
<White_Flame>
because of the different ways that lisp can bind variables to values, the notion of a "variable" is much more apparent than in most static languages
kuler has joined #commonlisp
srhm has quit [Quit: Konversation terminated!]
srhm has joined #commonlisp
pillton has joined #commonlisp
Inline has quit [Quit: Leaving]
Qwnavery has quit [Quit: WeeChat 3.2]
rain3 has joined #commonlisp
srhm has quit [Quit: Konversation terminated!]
srhm has joined #commonlisp
derelict has quit [Ping timeout: 258 seconds]
Qwnavery has joined #commonlisp
Oladon has quit [Quit: Leaving.]
lisp123 has joined #commonlisp
srhm has quit [Quit: Konversation terminated!]
srhm has joined #commonlisp
derelict has joined #commonlisp
pve has joined #commonlisp
Lord_of_Life_ has joined #commonlisp
Lord_of_Life has quit [Ping timeout: 258 seconds]
Lord_of_Life_ is now known as Lord_of_Life
srhm has quit [Read error: Connection reset by peer]
srhm has joined #commonlisp
lisp123 has quit [Remote host closed the connection]
lisp123 has joined #commonlisp
pranavats has left #commonlisp [Disconnected: Received SIGTERM]
lad has quit [Ping timeout: 268 seconds]
srhm has quit [Quit: Konversation terminated!]
srhm has joined #commonlisp
shka has joined #commonlisp
cosimone has joined #commonlisp
gethuen has quit [Quit: Connection closed for inactivity]
pranavats has joined #commonlisp
makomo has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
amb007 has quit [Ping timeout: 272 seconds]
amb007 has joined #commonlisp
Guest25 has joined #commonlisp
kuler has quit [Remote host closed the connection]
kuler has joined #commonlisp
attila_lendvai has joined #commonlisp
gaqwas has joined #commonlisp
Guest25 has quit [Quit: Client closed]
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
kuler has quit [Remote host closed the connection]
kuler has joined #commonlisp
<pjb>
Some of lad confusion came from this wrong assertion: "(nshuffle '(1 2 3) (sb-ext:seed-random-state 1 )) ;=> This always returns the same result".
<pjb>
It returns the same when this is evaluated (from a load of the source, or at the REPL), because in that case each time a new literal list (1 2 3) is read.
cosimone has quit [Remote host closed the connection]
<pjb>
But when you compile-file this expression, the compiler will read (1 2 3) once, and may store it either in read-only space or in read-write space.
<beach>
Nice catch.
<pjb>
In the former case, an error or a sigbus may occur. In the later case we'll get the same changing results as the other expression.
<beach>
Also, lad was confused about other things, like the difference between a variable and an object.
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
pillton has quit [Quit: ERC (IRC client for Emacs 27.2)]
amb007 has quit [Ping timeout: 268 seconds]
hendursa1 has joined #commonlisp
amb007 has joined #commonlisp
hendursaga has quit [Ping timeout: 244 seconds]
heisig has joined #commonlisp
<heisig>
Can someone tell me how I can access local variables with a #N suffix in the SLIME debugger (on SBCL)?
<heisig>
Those variables arise whenever a variable name is used more than once in the same scope.
<heisig>
And so far, I haven't managed to refer to them in the interactive 'e' evaluator within a stack frame.
lisp123 has quit [Remote host closed the connection]
lisp123 has joined #commonlisp
dsk has quit [Ping timeout: 272 seconds]
lisp123 has quit [Remote host closed the connection]
lisp123 has joined #commonlisp
srhm has quit [Quit: Konversation terminated!]
amb007 has quit [Read error: Connection reset by peer]
srhm has joined #commonlisp
amb007 has joined #commonlisp
<pjb>
heisig: good question.
<pjb>
heisig: 1- if you type RET on the frame, it shows all variables (that have not been optimized out), even those named with uninterned symbols.
<mfiano>
can you give some example code that produces these suffices?
<pjb>
heisig: 2- if you move the cursor on one of them, and type RET, the slime inspector will show you its value in more details.
<mfiano>
I cannot reproduce on Sly at least
<beach>
pjb: But you may want to use such a variable in a form that you type to eval-in-frame
<pjb>
heisig: 3- otherwise, if you want to access it from an expression you'd enter with e for example, the only way would be to have a reference to that variable name.
amb007 has quit [Read error: Connection reset by peer]
<pjb>
heisig: which is the point of using uninterned variable names in the first place, to prevent you to access it…
<mfiano>
You can M-RET to send the object to the REPL, and create a reference to it there which you could use in eval-in-frame
amb007 has joined #commonlisp
<mfiano>
Works even for uninterned symbols. I use it frequently
<pjb>
(defvar *saved-name*) (defun foo () (let ((#1=#.(let ((name '#:foo)) (setf *saved-name* name) name) 42)) (incf #1#) (/ #1# 0))) Then in slime with e on the frame, #.*saved-name* will return the value of the variable #:foo
<pjb>
The expression in the #1=#. would have to be more sophisticated if the code was compiled and loaded, since here the name is only saved in the compilation environment aka startup environment when you just load the source.
<pjb>
heisig: ^
<pjb>
In short it's possible, but inconvenient; don't do that. Use a flag in your macro to use normal symbols while debugging!
cage has joined #commonlisp
<mfiano>
What does that have to do with some #N suffix the debugger is adding to locals?
<heisig>
pjb: I wasn't talking about uninterned symbols, but symbols that were magically renamed by SBCL. SBCL sometimes converts a lexical variable A to A#1, ..., A#N.
<mfiano>
heisig: simple code example that exemplifies this renaming?
<heisig>
mfiano: Your trick with using M-RET to send the value to the REPL works perfectly. It is not ideal, but solves my problem.
<mfiano>
Ok good
amb007 has quit [Ping timeout: 245 seconds]
amb007 has joined #commonlisp
<beach>
mfiano: I wonder whether it is renaming due to SSA conversion, maybe.
<mfiano>
I don't know. I haven't ever seen this, or was able to reproduce it from heisig's description
<mfiano>
But I use a SLIME fork
<beach>
I see it all the time. I don't think it has to do with SLIME or SLY, but with how SBCL presents the stack-frame contents.
<pjb>
heisig: oh, in that case they are are normal symbols, so just use A#1
<mfiano>
Interesting, also use SBCL and spend quite a deal of time in the debugger
<pl>
I thought Python (CMU, SBCL and SCL) didn't do SSA?
<pjb>
sorry I read prefix instead of suffix.
<heisig>
Here is a minimal example that produces such a stack frame: (defun foo (x &aux (x (1+ x))) (break) (+ x x))
asarch has quit [Quit: Leaving]
amb007 has quit [Read error: Connection reset by peer]
<mfiano>
pjb: It's not a symbol, just an annotation to a symbol the debugger is presenting same symbols as IIUC
amb007 has joined #commonlisp
<heisig>
pjb: When I evaluate x#1 in that stack frame, I get "The variable |X#1| is unbound.". So it is definitely not just a symbol.
<mfiano>
Only need debug 3 and rest default compiler policy values
<beach>
mfiano: I take it debug 3 is not your default then.
<beach>
It is mine, which is why I see this all the time, just like heisig.
srhm has quit [Quit: Konversation terminated!]
<mfiano>
It is not. I do not modify the implementation's default compiler policy so I don't accidentally introduce bugs for the common user
srhm has joined #commonlisp
<beach>
Interesting point of view.
<pjb>
If you don't modify defaults, then how do you know your code is conforming?
<pjb>
Actually, you should compile your code in a loop trying all the combinations of default variations.
<mfiano>
When I need debug 3, I either do it to an individual function, or I modify the default compiler policy manually for a temporary image rather than a "always different" value from what the average user may be running my code with
<mfiano>
same for other optimizations
<mfiano>
debug 3 has special meaning for libraries such as static-dispatch that I use, too. When I'm quickly prototyping or running performance regression tests in my codes, I don't want a failure to remember a localized declaration to cause me to lose precious time
ahc has quit [Quit: Client closed]
Qwnavery has quit [Quit: WeeChat 3.2]
<mfiano>
(static-dispatch alters the semantics of method dispatch, so you could get a completely different method called with debug 3!)
<mfiano>
debug 3 means disable static dispatch
<beach>
Sounds very strange to me.
<mfiano>
Not really. Types can change dynamically at runtime. With static dispatch there is no runtime dynamic dispatch
<mfiano>
It's pretty clear
<beach>
What sounds strange to me is that a library would completely change its algorithms based on the DEBUG level.
<mfiano>
It makes sense to me. debug 3 is more debuggable, so there is no inlining.
<beach>
I mean, there is not even a standard way of querying the DEBUG level as far as I know.
<beach>
But inlining doesn't change any algorithms.
<mfiano>
Sure, the whole library makes use of a CLtL2 environments portability library.
<beach>
I totally do not expect any library to alter its algorithms as a result of my changing the DEBUG level. That's why I think it is strange.
<mfiano>
There is no algorithm being altered
<beach>
From static to dynamic dispatch?
<mfiano>
Static-dispatch works by inlining a method function's body according to statically determined environment information, at compile time.
<mfiano>
If you want debuggability, you might want to see the method call's frame and arguments used for dispatch
<mfiano>
Which implies disabling inlining the method function's body
nij- has joined #commonlisp
lisp123 has quit [Remote host closed the connection]
lisp123 has joined #commonlisp
scymtym has quit [Ping timeout: 268 seconds]
amb007 has quit [Ping timeout: 252 seconds]
amb007 has joined #commonlisp
lisp123 has quit [Ping timeout: 256 seconds]
<mfiano>
I wouldn't say there is another algorithm, as it's the same Common Lisp generic function's method combination algorithm, just invoked at a different time (not runtime), which can alter the result.
<hayley>
Wow, they even ported non-dispatching dispatch to Common Lisp. How modern!
lisp123 has joined #commonlisp
<hayley>
The semantics are totally different under static dispatch, as it turns an assumption like "the argument X is of type FOO" into "the class of the argument X is exactly FOO".
heisig has quit [Quit: Leaving]
<hayley>
Thought I had more to say, but it is very strange that removing the optimization completely changes semantics.
amb007 has quit [Ping timeout: 268 seconds]
amb007 has joined #commonlisp
lisp123 has quit [Remote host closed the connection]
lisp123 has joined #commonlisp
<beach>
Without checking what any implementation returns, what do you think this form should return: (destructuring-bind (&whole x a) (list 1) (list x a)) ?
<hayley>
((1) 1)?
<beach>
I think ((list 1) 1)
<beach>
But your answer is what SBCL does.
<hayley>
So, the value of the &whole variable should be unevaluated?
<beach>
It would be if my thinking is acceptable.
lad has joined #commonlisp
<mfiano>
Same result on ECL and CCL
<hayley>
The first sentence in the description of DESTRUCTURING-BIND suggests all binding is done on the structure resulting from the evaluation of the expression, so it isn't immediately obvious. But sometimes the standard is like that.
<beach>
Yeah, that phrase suggests that the form is evaluated and only its value is then considered.
<beach>
Thanks.
scymtym has joined #commonlisp
<hayley>
Then 3.4.5 Destructuring Lambda Lists defers to 3.4.4 Macro Lambda Lists, which only describes &whole in terms of a macro function.
<hayley>
"&whole is followed by a single variable that is bound to the entire macro-call form; this is the value that the macro function receives as its first argument." I guess the value our fictive "macro function" receives is the result of evaluation still.
<Colleen>
scymtym: Got it. I'll let heisig know as soon as possible.
<hayley>
In my worthless opinion, having a strange subject of destructuring would have been avoided if they wrote 3.4.4 to be an "extension" of 3.4.5, with the latter describing how to destructure by destructuring lambda lists, and the former introducing &environment.
Posterdati has quit [Ping timeout: 268 seconds]
dsk has joined #commonlisp
<beach>
hayley: I now think the behavior of implementations is correct. There are two lambda lists involved here which made me confused. The lambda list of the macro destructuring-bind and that of its argument. A &whole parameter of the former would have (list 1) as its value.
<beach>
Anyway, time for a lunch break.
<hayley>
Right.
amb007 has quit [Read error: Connection reset by peer]
random-nick has joined #commonlisp
amb007 has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
Posterdati has joined #commonlisp
attila_lendvai has quit [Ping timeout: 248 seconds]
amb007 has quit [Ping timeout: 245 seconds]
kakuhen has quit [Quit: Leaving...]
srhm has quit [Read error: Connection reset by peer]
srhm has joined #commonlisp
amb007 has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
frgo has quit [Remote host closed the connection]
frgo has joined #commonlisp
CrashTestDummy2 has quit [Quit: Leaving]
amb007 has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
amb007 has quit [Ping timeout: 268 seconds]
amb007 has joined #commonlisp
fpc has left #commonlisp [#commonlisp]
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
igemnace has quit [Quit: WeeChat 3.2]
tyson2 has joined #commonlisp
Qwnavery has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
Qwnavery has quit [Client Quit]
CrashTestDummy has joined #commonlisp
lisp123_ has joined #commonlisp
lisp123 has quit [Ping timeout: 245 seconds]
srhm has quit [Quit: Konversation terminated!]
srhm has joined #commonlisp
bendersteed has joined #commonlisp
bendersteed has left #commonlisp [ERC (IRC client for Emacs 27.2)]
lotuseater has joined #commonlisp
attila_lendvai has joined #commonlisp
dsk has quit [Ping timeout: 256 seconds]
yitzi has joined #commonlisp
attila_lendvai has quit [Quit: Leaving]
jon89 has quit [Quit: Client closed]
yitzi has quit [Remote host closed the connection]
attila_lendvai has joined #commonlisp
yitzi has joined #commonlisp
gethuen has joined #commonlisp
Josh_2 has joined #commonlisp
Josh_2 has quit [Remote host closed the connection]
attila_lendvai_ has joined #commonlisp
attila_lendvai has quit [Ping timeout: 248 seconds]
hendursa1 has quit [Quit: hendursa1]
hendursaga has joined #commonlisp
Bike has joined #commonlisp
srhm has quit [Quit: Konversation terminated!]
lisp123_ has quit [Remote host closed the connection]
srhm has joined #commonlisp
lisp123 has joined #commonlisp
lisp123 has quit [Read error: Connection reset by peer]
Josh_2 has joined #commonlisp
srhm has quit [Read error: Connection reset by peer]
<Josh_2>
Hello
srhm has joined #commonlisp
<beach>
Hello Josh_2.
<Josh_2>
Hi beach, how is your work coming along?
selwyn has joined #commonlisp
<beach>
Very well, thank you. I am completely rewriting the code for manipulating lambda lists, because the previous one was wrong, but I am almost done.
<beach>
How about yourself?
<Josh_2>
That is good!
<Josh_2>
Mine is going well, nice and steady progress
<beach>
Great!
<hexology>
beach: hi, thanks for the tip about funcall earlier. and yes, i realize that there is no distinct "lambda" type in lisp and should have been more precise. that puts a damper somewhat on the usefulness of partial function application. would it be silly to rewrite `partial` as a macro that expands to a lambda form?
lisp123 has joined #commonlisp
<hexology>
i also have to say, CCL gave a much nicer error message than SBCL in this case
<beach>
hexology: Let me consult your code again...
tyson2 has quit [Quit: ERC (IRC client for Emacs 27.2)]
<beach>
I think PARTIAL is fine as it is. FUNCALL is just part of the language.
<jcowan>
hexology: But it is practical to write a macro also
attila_lendvai_ has quit [Ping timeout: 272 seconds]
<beach>
jcowan: Not really. You won't be able to return a closure for instance.
<beach>
... and that is what is being done here.
<hexology>
beach that's fair. and i suppose you don't want this as much in lisp as you might want in other languages, because flet lets you do this on an ad-hoc basis
<hexology>
and if you were writing a function that you intended to be "longer-lived" then partial application might be too much abstraction anyway
<beach>
No, the abstraction is useful. It is known as "Currying", and I am pretty sure you have functions for it in Alexandria.
<hexology>
honestly i think haskell-style currying tends to be hard to read... a little point-free style here and there isn't bad, but it can get excessive and create a lot of mental overhead
<beach>
Having said that, I should add that this, somewhat extreme, functional style, is not that much used in Common Lisp. Much of modern Common Lisp code uses CLOS-style "object-oriented" programming with generic functions and standard classes.
<hexology>
indeed, that is what i've seen. i think lisp strikes a nice balance
<beach>
Though, functional style is of course occasionally useful. You see it in macro expanders for instance.
<hexology>
as in, in the implementation of a macro expandeR?
<beach>
As in the body of DEFMACRO forms.
<akater[m]>
beach: What do you need for lambda-list? I have a macro `do-destructuring-lambda-list` which walks them, maybe it could be useful?
<beach>
akater[m]: I am working on writing a Common Lisp implementation, so I need lots of functionality on lambda lists, hence the module for that purpose.
<beach>
minion: Please tell akater[m] about SICL.
<minion>
akater[m]: SICL: SICL is a (perhaps futile) attempt to re-implement Common Lisp from scratch, hopefully using improved programming and bootstrapping techniques. See https://github.com/robert-strandh/SICL
<akater[m]>
beach: I'm aware of SICL
<beach>
OK.
<beach>
Destructuring needs to be somewhat specific. For example, the error conditions signaled when there are too few or too many arguments, when there is an odd number of keyword arguments, etc., need to be such that the source tracking can pick up the source location of the macro form that caused the problem.
<lotuseater>
beach: Does your macro also signal a condition if &OPTIONAL and &KEY are used without isolation? I mean for example (defun foo (x &optional y &key z) ...)
<beach>
Since that is allowed, no condition is currently signaled, but a style warning could be signaled I guess.
<akater[m]>
beach: Well, here's a webpage with elisp version. I have one for CL too, it's not published. Search for do-destr : https://gitlab.com/akater/elisp-akater-misc/-/blob/master/akater-misc-macs.org (Direct links to sections in rendered org pages in Gitlab do not seem to be supported, sorry.) If you find it useful, I could submit a CL version to SICL and add tests. There are some after the definition, already.
<lotuseater>
Okay.
<jcowan>
beach: How do you currently track source locations?
<beach>
akater[m]: Thanks, but signaling simple errors won't do.
<beach>
jcowan: We have a library called "Concrete Syntax Tree" that wraps each S-expression in a standard object that contains source information. And Eclector is able to return such CSTs.
<beach>
jcowan: Then we have code that attempts to re-create a CST after macro expansion, so that source information is preserved as much as possible.
<jcowan>
Okay, I guess that's a reasonable good-enough solution.
<beach>
Do you have a better one?
<yitzi>
I've also used eclector and the cst library to do line and column tracking versus the default stream position only tracking. Both are very cool libraries.
<Bike>
i think racket syntax objects are the same kind of thing, or at least they include source locations in addition to hygienic macro stuff
<jcowan>
Not given the constraint that macro bodies have to work on plain S-expressions, no. You might want to expose the conversion functions so that a macro can choose to work directly at the CST level.
<beach>
jcowan: scymtym has plans in that direction.
<jcowan>
Bike: You're right, but it does expose conversions between raw S-expressions and syntax objects. The issues arise when a macro call's arguments contain calls to other macros arbirarily deep.
<beach>
akater[m]: I canonicalize my lambda lists for a variety of further processing stages, and the canonicalization does a lot of error checking. So further processing stages can work with canonicalized lambda lists and avoid checking those errors each time.
srhm has quit [Quit: Konversation terminated!]
srhm has joined #commonlisp
<akater[m]>
beach: OK then. SICL is exciting. Unfortunately, I have too much unfinished projects to help with it. This one just felt like it could be an easy contribution.
<beach>
I understand. Thanks for trying.
<lotuseater>
I should try sometime myself how to write a macro for a lambda that is able to handle &REST, &OPTIONAL, &KEY from one with fixed arglist.
<lisp123>
beach: I read somewhere that SBCL doesn't use CLOS for built-in types (a good chance I read wrong). Is SICL using CLOS for all built-in types and does this mean you can get equivalent performance from CLOS vs. other data structures (the general comment has been structures are faster than classes due to avoiding looking up methods in the dispatch table)
<akater[m]>
lisp123: Standard has some restrictions re: built-in classes.
<scymtym>
jcowan: beach was referring to this: https://github.com/scymtym/s-expression-syntax/ . the basic idea is that a client must implement protocol functions for telling whether an input is a cons, for retrieving the car/cdr, for telling whether an input is a symbol, for retrieving the symbol name/package, etc. if that is the case, the library can parse any data structure as if it were an ordinary s-expression
<lisp123>
akater[m]: Oh I see, I will look into that - thanks
<beach>
lisp123: It depends on what you mean by built-in types. For certain classes that can have direct instances, like FIXNUM, SINGLE-FLOAT, CHARACTER, CONS, SICL has special representations with tagged pointers. For everything else, SICL uses standard classes.
nij- has quit [Quit: Using Circe, the loveliest of all IRC clients]
<lisp123>
beach: Thanks
<beach>
So, for instance, in SICL I do (defclass symbol () ((... symbol-name) (... symbol-package)))
<lisp123>
I am curious if classes can be made as efficient as strucutures (DEFSTRUCT)
<lisp123>
So if structures are implemented as classes, that would imply there is a way to make classes also as fast
<beach>
lisp123: Pleasure. In SBCL, you have a number of kludges that are required because CLOS is not loaded until late. So you can't do (defclass standard-class (...) ...) in SBCL.
<lisp123>
beach: Does that mean SBCL has an 'advantage' for efficiency?
<beach>
I believe SBCL does not require an indirection for certain built-in types for which SICL does require an indirection.
<beach>
lisp123: But on the other hand, for SICL, we have invented a number of efficiency-improving techniques, so I am not worried. In particular, I count a lot on call-site optimization as in the ELS paper.
<lisp123>
beach: Nice, that's nice to hear. I will read that paper out of curiosity when I have time
amb007 has quit [Read error: Connection reset by peer]
<beach>
lisp123: We also invented better generic-function dispatch, path replication, and more.
amb007 has joined #commonlisp
<lisp123>
Nice. I am leaning towards working more and more with generic functions where possible. After learning about :before and :after, they are even more useful than before
<beach>
Right. And, rather than introducing special cases all over the place, I much prefer to use a general mechanism like generic functions, and invent ways to make this mechanism sufficiently fast.
<beach>
I just don't have the work capacity to maintain code with lots of special cases.
<lisp123>
That seems like a smart way to do things
<beach>
And my brain is too small to write modules in a Common Lisp subset, like the SBCL compiler not using generic functions as I have been told, so each module uses the full language.
tyson2 has joined #commonlisp
<lisp123>
And thus, Common Lisp can be argued to be fully an OO language :D
<lotuseater>
lisp123: not quite fully, but in the backstage more things happen than the eye expects first
waleee has quit [Ping timeout: 240 seconds]
<beach>
Since there is no widely agreed-upon definition of "OO language", this issue could be debated to death.
<lotuseater>
beach: So we don't have to. :)
selwyn has quit [Read error: Connection reset by peer]
waleee has joined #commonlisp
ec has joined #commonlisp
<White_Flame>
Java is an OO language. Object Obsessed.
<beach>
*sigh*
<lotuseater>
White_Flame: the forcing on what they call so in Java makes it very unattractive
<White_Flame>
but Lisp is an OO (Obviously Optimal) language
lisp123 has quit [Remote host closed the connection]
ec has joined #commonlisp
lisp123_ has joined #commonlisp
lisp123_ has quit [Ping timeout: 245 seconds]
doyougnu has joined #commonlisp
taiju has quit [Ping timeout: 268 seconds]
selwyn has quit [Read error: Connection reset by peer]
taiju has joined #commonlisp
ec has quit [Ping timeout: 244 seconds]
Fedoreo has joined #commonlisp
amb007 has quit [Ping timeout: 272 seconds]
amb007 has joined #commonlisp
attila_lendvai has joined #commonlisp
lisp123 has joined #commonlisp
attila_lendvai has quit [Remote host closed the connection]
attila_lendvai has joined #commonlisp
tfeb has joined #commonlisp
ec has joined #commonlisp
tfeb has quit [Client Quit]
lisp123 has quit [Ping timeout: 248 seconds]
ircseeker3 has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
srhm has quit [Quit: Konversation terminated!]
srhm has joined #commonlisp
Fedoreo has quit [Remote host closed the connection]
amb007 has quit [Ping timeout: 256 seconds]
amb007 has joined #commonlisp
CrashTestDummy2 has joined #commonlisp
CrashTestDummy has quit [Ping timeout: 248 seconds]
ec has quit [Ping timeout: 244 seconds]
srhm has quit [Quit: Konversation terminated!]
srhm has joined #commonlisp
lisp123 has joined #commonlisp
ec has joined #commonlisp
srhm has quit [Quit: Konversation terminated!]
lisp123 has quit [Remote host closed the connection]
lisp123 has joined #commonlisp
srhm has joined #commonlisp
lisp123_ has joined #commonlisp
selwyn has joined #commonlisp
lisp123 has quit [Ping timeout: 268 seconds]
CrashTestDummy3 has joined #commonlisp
hafat has joined #commonlisp
CrashTestDummy2 has quit [Ping timeout: 268 seconds]
<lisp123_>
Is it possible to add IRC logging to #clschool? It would be useful to go through questions that others asked and also in case one logs off before a question is answered
<mfiano>
Logging is done by people who visit a channel, that means you.
<mfiano>
Shinmera doesn't visit #clschool. Most people just log on their own with their IRC client
<Bike>
the logs are done by colleen, shinmera's bot
<Bike>
which is in several channels shinmera is not in
<Bike>
you could prolly just ask. i don't know that shinmera has an application process
<mfiano>
Maybe it responds to /invite then
<mfiano>
Or that
<lisp123_>
Bike: thanks, I will ask him
<alphapapa[m]>
<lisp123_> "Is it possible to add IRC..." <- You could use the channel through the Matrix bridge and then have access to the room's history that way
srhm has quit [Quit: Konversation terminated!]
<lisp123_>
alphapapa[m]: But then I would have to use Matrix no :)? LimeChat is serving me well
srhm has joined #commonlisp
<Bike>
you could also set up a bouncer so you have 24/7 logs
<Bike>
for yourself
<alphapapa[m]>
lisp123_: Matrix is pretty cool and easy to use. My Emacs client works pretty well. :)
<Bike>
i guess that doesn't help much if you're trying to link a newbie to a previous answer
notzmv has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
<lisp123_>
I guess one could also write some elisp and use ERC and save the buffer to file. But I just tweeted Shinmera which seemed to be the path of least resistance :)
amb007 has joined #commonlisp
<edgar-rft>
Wouldn't it make more sense to collect solutions to common questions in some public document repository like the "Common Lisp Cookbook"?
yitzi has quit [Quit: Leaving]
<lisp123_>
alphapapa[m]: Nice :)
<lisp123_>
edgar-rft: Its more for just reading through what people are asking - sometimes can learn useful stuff from that. Whereas Cookbook is very detailed so is better suited for "recipes" - I wouldn't necessarily go there to figure out why to use gensym within macros for example
<lisp123_>
Which was a question I asked earlier (thanks PJB!) and now I manually saved it in my notes files
<lisp123_>
very detailed / too large & exhaustive to search through at times
selwyn has quit [Read error: Connection reset by peer]
ec has quit [Ping timeout: 244 seconds]
<pjb>
lisp123_: there are reasons why some channels are not logged. We want that newbies don't be ashamed of asking any kind of questions in #clschool; for this it's not logged (publically). you can always use a bot to make a local log; note that erc can log your channels while you're connected.
<pjb>
lisp123_: in particular, the search engine I tried (montezuma) doesn't satisfy me.
<lisp123_>
pjb: Thanks, I'll have a look. I think I can just get ERC to log for me since I have a machine thats always on
<pjb>
M-x customize-group RET erc-log RET
<lisp123_>
pjb: Thanks!
gethuen has quit [Quit: Connection closed for inactivity]
hhdave_ has quit [Ping timeout: 276 seconds]
hhdave has joined #commonlisp
ec has joined #commonlisp
sm2n has left #commonlisp [Leaving]
sm2n has joined #commonlisp
srhm has quit [Quit: Konversation terminated!]
srhm has joined #commonlisp
amb007 has quit [Ping timeout: 252 seconds]
<Josh_2>
Whats the library for handling bzip files?
<Josh_2>
I saw it yesterday and now I cannot remember it :(
sander has quit [Read error: Connection reset by peer]
<mfiano>
chipz is one
sander has joined #commonlisp
<Josh_2>
Thats the one
amb007 has joined #commonlisp
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
selwyn has joined #commonlisp
amb007 has quit [Ping timeout: 248 seconds]
hendursaga has quit [Remote host closed the connection]
amb007 has joined #commonlisp
lisp123_ has quit [Quit: Leaving...]
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
hendursaga has joined #commonlisp
nij- has joined #commonlisp
<nij->
Just curious. Suppose I want to edit a line in a huge file using lisp, is there a way to do that without reading the whole file into the memory?
<Josh_2>
with-open-file doesn't load the entire file into memory
<Josh_2>
You can use file-position to change line
<lotuseater>
so from another point of view: it's possible with C or sed, so *how* do I do it? ^^
<Shinmera>
file-position doesn't help with lines.
<Shinmera>
just call read-line until you're at the desired line number.
<Shinmera>
or manually read-char until you've seen the desired number of Linefeeds
<nij->
I plan to go through a file line by line, check if that line satisfies a pred, and make change only to that line if T.
<nij->
Currently my code is very ugly.. I read and write the whole file every time :(
lisp-newbie has joined #commonlisp
thomasbartscher has joined #commonlisp
Inline has joined #commonlisp
thomasbartscher is now known as Aksej
<lisp-newbie>
quick question: I have a class definition, and then functions where I use that class definition, and I want to make a way to just pass in a name of a class and generate functions for that class. Would I use a function for that? Or is that already what a macro is for?
rain3 has quit [Ping timeout: 245 seconds]
<lisp-newbie>
Meaning I want to automatically generate functions for an arbitrary class that I pass in
<lotuseater>
that is what macros are also for
azimut_ has joined #commonlisp
<Bike>
Usually you want to generate code at build time as much as you can
<mfiano>
if the class name is available at compile time
<lotuseater>
lisp-newbie: An important difference is, a function first evaluates all of its arguments, a macro takes forms and gives back another or multiple forms as specified.
<lisp-newbie>
yeah, class name is available at compile time
<mfiano>
or rather, macro-expansion time
<lisp-newbie>
got this error when I tried to do it as a function: The NAME argument to DEFUN, (CONCATENATE 'STRING MODEL-NAME; "-get"), is not a function name.
<mfiano>
Right
<lotuseater>
you can try out a macroexpand for '(defstruct person name age) then you'll see that also some functions are built for that
<mfiano>
defun is a macro
<Bike>
i'm going to guess that you wanted the concatenation to happen at macroexpansion time, but left it in the expansion instead by mistake
azimut has quit [Ping timeout: 244 seconds]
<lotuseater>
also DEFMACRO is a macro xD
<lisp-newbie>
Bike well I defined it as a defun not a defmacro
<lisp-newbie>
I've never done a macro before, but that was kind of the whole point I've started to learn lisp for, so I think finally I have arrived at the beginning of the purpose of this journey
<lisp-newbie>
are function names strings? If I want to define functions in a macro? oh I guess I can macro expand defstruct
<lotuseater>
lisp-newbie: sometimes it's useful defining functions outside a macro that build lists out of other lists or such that your macro needs
<moon-child>
names in general are called _symbols_
<lisp-newbie>
That's what I've been using and lisp cookbook
<lotuseater>
a good start :)
<alphapapa[m]>
lisp-newbie: Ok, so if you're wanting to move into macros, maybe see "On Lisp". PG has it in PDF form on his site for free.
<mfiano>
and much later Let Over Lambda
<lotuseater>
or a bit smoother the chapter about them in Land of Lisp
<mfiano>
PCL should be finished before starting to write code though
<lisp-newbie>
alphapapa thanks, I have the pdf already :) I just thought it was too advanced for where I'm at
<lotuseater>
mfiano: good advise, LOL is covering pretty advanced stuff ^^
<alphapapa[m]>
lisp-newbie: The early chapters probably aren't over your head, at least
<mfiano>
and pretty opinionated unorthodox code
<mfiano>
But good learning resource on macro writing regardless
<lotuseater>
oh yes
<lisp-newbie>
mfiano before starting to write code? I am doing a project as a way to learn, I find it hard to go through the book, but this way whenever difficulties arise, I now have much more motivation to read the chapters
<mfiano>
lisp-newbie: Right
<alphapapa[m]>
lisp-newbie: On Lisp may also have the effect of whetting your appetite for more Lisp
<mfiano>
I fear you won't be learning properly and going against the path of least resistance. Macros are easy if you follow a linear path the book sets you on
<lisp-newbie>
mfiano which is opinionated code let over lambda or on lisp?
<Josh_2>
the former
<lisp-newbie>
alphapapa I have pretty much read every chapter in PCL up until the second macro chapter, which I stopped because I could progress with the project up until that point, now I think it makes sense to jump in
<alphapapa[m]>
lisp-newbie: Happy Lisping :)
<lotuseater>
just read or also trying out and changing stuff?
<Josh_2>
I think understanding of macros comes as you write more lisp
<lisp-newbie>
I have developed software as a software engineer for a while, so besides macros, I feel eevrything else is just syntax and about knowing which functions to use and well, lisp does have quite a few differences in how packages work and nuances in things
<lisp-newbie>
thanks :D
<lisp-newbie>
lotuseater using it for a project :)
<lotuseater>
Josh_2 mfiano the best is this "Heureka" moment when it makes click in the head :3
<nij->
I dunno why using central-registry is discouraged..
<Bike>
you're supposed to use the configuration stuff, which is probably more composable, but also like a fuckton more complicated
<nij->
What do you mean by composable?
<Bike>
like a bunch of different systems can define their own configurations and things work together harmoniously.
<lotuseater>
or you start better with something small
<Josh_2>
Just write some macros...
<mfiano>
Read PCL, not implementation internals!
<Bike>
defstruct is not a good example
<lotuseater>
lisp-newbie: for example how to write a macro LET1 when you just have one binding in a LET form and don't want to write doubly parentheses
<lotuseater>
Bike: right, and then it's this SBCL code
<Bike>
yeah the deep sbcl magic doesn't help
<Josh_2>
write a while macro or something
<mfiano>
Start with simple reproductions like AND
Aksej has quit [Client Quit]
Aksej has joined #commonlisp
nij- has quit [Ping timeout: 245 seconds]
<lisp-newbie>
Bike lotuseater mfiano Josh_2 right, I only meant it for later, I'm trying to turn this into a working macro: https://pastebin.com/0YjcSNeu
<lisp-newbie>
mfiano yeah, I read those in the PCL book, I finished that chapter
<Josh_2>
wat
<Josh_2>
You need to read the chapters in PCL on macros
Aksej has quit [Client Quit]
<Bike>
You seem to not be quoting the code create-model-functions is supposed to return.
Aksej has joined #commonlisp
<Bike>
You're just writing the code in there. So the macroexpander will try to define the functions, not the code it returns.
<Josh_2>
What you are doing is perfectly possible but you are not doing it correctly
<Bike>
Assuming I'm guessing how your annotation reader macros work correctly.
Aksej has quit [Client Quit]
<mfiano>
Also note a macro returns a single form, not many. This is a major use-case for PROGN
Aksej has joined #commonlisp
<mfiano>
You will need to learn quoiting and unquoting, and how a macro transforms data. PCL covers all of this
<mfiano>
I think the path you are on is why many people give up
<Josh_2>
yes, you need to read the chapters on macros in PCL
<Josh_2>
and experiment, copy the code and inspect it with sly/slime and you will start to understand what is going on
<Josh_2>
soon you will be writing macro writing macros, no problems
<Josh_2>
also you could do what you are trying to do in that code with generic functions
srhm has quit [Quit: Konversation terminated!]
<mfiano>
and don't read the chapter on macros. You will be missing important macro writing pre-requisites in previous chapters
<mfiano>
The book is meant to be read linearly
srhm has joined #commonlisp
nij- has joined #commonlisp
<Josh_2>
one superclass for all of your models then generics like 'delete-model' 'update-model' etc and you can then create more specific versions if you need special behaviour on various subclasses
<Josh_2>
mfiano: they said they had already read PCL
<Josh_2>
most of it anyway
<mfiano>
I do not believe that
<lisp-newbie>
yeah, I'm going to read the PCL chapter and then try to do it... I was just sharing what my goal is
<mfiano>
Sigh
<lisp-newbie>
mfiano I read the previous chapters of PCL already
<lisp-newbie>
thanks
<lisp-newbie>
thanks Josh_2 will keep those in mind after I read the PCL chapters, then I will give it a go
<lisp-newbie>
Bike the annot is a cl-annot, not my macro...
<Bike>
eh, whichever.
<Bike>
Josh_2 is probably right that this could be better accomplished through CLOS
<lisp-newbie>
I read most of the chapters before chapter 8
<Josh_2>
you do not need that reader macro if you do that with a macro, you can just have the export form
<lotuseater>
lisp-newbie: do you already know what the @ from cl-annot really is?
<lotuseater>
and we surely want you to become powerful :)
lisp123 has joined #commonlisp
<mfiano>
lisp-newbie: Can you explain what ,@ does?
<lisp-newbie>
yeah, the supper class would be nice, but I'm calling a macro from some other package that defines classes, and I'm trying to work with that package
<Josh_2>
That doesn't matter...
<Josh_2>
you can just subclass their class and everything will still work
<lisp-newbie>
lotuseater the @ is not lisp @ it's a python like @ for annotations it expands into (export something (progn etc
<Josh_2>
if they define a class in their package like package:my-class you can still do (defclass myclas (package:my-class) ..)
<mfiano>
No, ",@"
<mfiano>
The part of macros you already read about
<lisp-newbie>
Josh_2 but I'm using their macro to create many different classes
<lisp-newbie>
and I want to create the functions for those classes
<mfiano>
lisp-newbie: Hint: It is explained before the macro chapters, one of many reasons you should read the book without skipping around.
<Josh_2>
alrighty
<lisp-newbie>
mfiano that's the next PCL chapter that I'm about to read
<mfiano>
Which?
<lisp-newbie>
oh hahaha mfiano OK, you got me
<Josh_2>
You might find if you inspect their macro you can see what superclass they use for each of the classes automatically defined, you can then create generics that specialize on that
<lisp-newbie>
Josh_2 ah, that's a nice idea, will look into it
<lisp-newbie>
ok, got to run to a meeting, thank you guys!
lisp-newbie has quit [Quit: This computer has gone to sleep]
<lotuseater>
ack
<mfiano>
Well, I tried to set them on a decent learning path. I'm not sure they want to listen though
<lotuseater>
maybe they need time
<Josh_2>
I dont think I've read PCL cover to cover yet
<lotuseater>
I offered him to go through this possible LET1 step by step.
<Josh_2>
I know i've read a few chapters over and over again
<mfiano>
lotuseater: I know. It seems they want to jump into an application, no matter how difficult that may be.
<lotuseater>
yeah it's different from most other stuff
<mfiano>
Maybe he will learn to swim in the deep end, but it may produce bad habits with regard to code style and idioms
<lotuseater>
that needs practice (and more asking of others)
<lotuseater>
or there's also being too overenthusiastic with things
<pjb>
nij-: about your file modification, the question you must answer is what to do if the new line is not of the same length as the old one? If it's shorter, you could pad it with spaces. If it's longer how do you deal with it?
nij- has quit [Ping timeout: 256 seconds]
<pjb>
nij-: your file could contain fixed-length lines. eg. all lines could be 80-character (like a deck of punched cards).
<pjb>
nij-: in that case the question that remains to ask yourself, is what to do if you want to remove or add lines.
srhm has quit [Quit: Konversation terminated!]
srhm has joined #commonlisp
mfiano has quit [Ping timeout: 258 seconds]
nij- has joined #commonlisp
pve has quit [Quit: leaving]
nij- has quit [Remote host closed the connection]
srhm has quit [Quit: Konversation terminated!]
srhm has joined #commonlisp
scymtym has quit [Ping timeout: 252 seconds]
shka has quit [Ping timeout: 268 seconds]
lisp123 has quit [Remote host closed the connection]
lisp123 has joined #commonlisp
lisp123 has quit [Remote host closed the connection]
lisp123 has joined #commonlisp
lisp123 has quit [Remote host closed the connection]
lisp123 has joined #commonlisp
scymtym has joined #commonlisp
lisp123 has quit [Ping timeout: 272 seconds]
karlosz has joined #commonlisp
attila_lendvai has quit [Ping timeout: 272 seconds]
cage has quit [Quit: rcirc on GNU Emacs 27.1]
lisp123 has joined #commonlisp
srhm has quit [Quit: Konversation terminated!]
srhm has joined #commonlisp
lisp123 has quit [Ping timeout: 248 seconds]
selwyn has quit [Quit: Leaving]
amb007 has quit [Ping timeout: 245 seconds]
khrbt has joined #commonlisp
khrbt has quit [Changing host]
amb007 has joined #commonlisp
karlosz has quit [Quit: karlosz]
ircseeker3 has quit [Remote host closed the connection]
dsk has joined #commonlisp
akoana has joined #commonlisp
Oddity has quit [Ping timeout: 268 seconds]
srhm has quit [Quit: Konversation terminated!]
srhm has joined #commonlisp
makomo_ has joined #commonlisp
frgo has quit [Remote host closed the connection]
frgo has joined #commonlisp
sjl has quit [Quit: WeeChat 2.2-dev]
makomo has quit [Ping timeout: 268 seconds]
kakuhen has joined #commonlisp
Alfr has quit [Remote host closed the connection]
luna-is-here has quit [Ping timeout: 252 seconds]
Alfr has joined #commonlisp
Inline_ has joined #commonlisp
scymtym has quit [Ping timeout: 256 seconds]
Inline has quit [Ping timeout: 272 seconds]
luna-is-here has joined #commonlisp
makomo has joined #commonlisp
edgar-rft has quit [Ping timeout: 272 seconds]
makomo_ has quit [Read error: Connection reset by peer]
makomo__ has joined #commonlisp
gaqwas has quit [Ping timeout: 268 seconds]
edgar-rft has joined #commonlisp
scymtym has joined #commonlisp
makomo has quit [Ping timeout: 248 seconds]
amb007 has quit [Ping timeout: 272 seconds]
makomo__ has quit [Quit: WeeChat 3.0.1]
makomo has joined #commonlisp
srhm has quit [Quit: Konversation terminated!]
srhm has joined #commonlisp
scymtym_ has joined #commonlisp
scymtym has quit [Ping timeout: 268 seconds]
igemnace has joined #commonlisp
edgar-rft has quit [Ping timeout: 248 seconds]
edgar-rft has joined #commonlisp
jeosol has quit [Ping timeout: 248 seconds]
derelict has quit [Quit: WeeChat 3.2]
Oddity has joined #commonlisp
srhm has quit [Read error: Connection reset by peer]
srhm has joined #commonlisp
random-nick has quit [Ping timeout: 245 seconds]
copec has joined #commonlisp
akoana has left #commonlisp [#commonlisp]
kulernil has joined #commonlisp
dlowe has joined #commonlisp
dieggsy has quit [Ping timeout: 252 seconds]
icepic1984[m] has quit [Ping timeout: 240 seconds]
etimmons has quit [Ping timeout: 252 seconds]
JooTvora[m] has quit [Ping timeout: 252 seconds]
akater[m] has quit [Ping timeout: 245 seconds]
happy-dude has quit [Ping timeout: 268 seconds]
kuler has quit [Remote host closed the connection]