jackdaniel changed the topic of #lisp to: Common Lisp, the #1=(programmable . #1#) programming language<http://cliki.net/> logs:<https://irclog.whitequark.org/lisp,http://ccl.clozure.com/irc-logs/lisp/> | SBCL 1.4.5, CMUCL 21b, ECL 16.1.3, CCL 1.11.5, ABCL 1.5.0
fikka has joined #lisp
nirved has quit [Ping timeout: 252 seconds]
debsan has quit [Ping timeout: 240 seconds]
fikka has quit [Ping timeout: 252 seconds]
anamorphic has quit [Ping timeout: 244 seconds]
debsan has joined #lisp
yvy2 has joined #lisp
yvy2 has quit [Client Quit]
pjb has quit [Ping timeout: 264 seconds]
<didi> equwal: Interesting idea.
<didi> I think I've never deeply messed with packages, aside from exporting some symbols.
<equwal> They're important. Just make a package so you wont clobber cl-user and you're good to go.
<didi> equwal: Ah, yes. I do it like that. I have some packages (and their systems). But I don't think I've played any advanced game yet.
<equwal> Like no ASDF?
<didi> equwal: s/systems/ASDF systems
<equwal> If you are working from in a package you can make it external but not import it so you access it with package-name:intersection leaving the standard alone.
fikka has joined #lisp
<equwal> Within the package you would probably shadow it.
<equwal> Try running (defpackage test) (in-package :test) in repl.
<didi> equwal: Thank you. I just tried a little shadow dance with `+' and it worked. Cool.
fikka has quit [Ping timeout: 252 seconds]
esper0s has quit [Read error: No route to host]
fikka has joined #lisp
fikka has quit [Ping timeout: 240 seconds]
terpri has joined #lisp
meepdeew has quit [Remote host closed the connection]
robotoad has joined #lisp
<equwal> How can I change a regular character like #\f to a read macro without a dispatch character? This way I can call a read macro as if it were a function (fn...)?
mejja has joined #lisp
<Bike> set-macro-character
<equwal> Yes but the problem I have is that I can't do it without breaking the reader.
<Bike> Breaking?
<Bike> also i don't know what you mean by the "as if it were a function" bit.
<equwal> Well the idea is to do something like (brainfuck ++>+)
<Bike> that doesn't seem like a reader macro
<no-defun-allowed> don't think you need one
<Bike> you want to do, like, arbitrary parsing, but also keep parentheses working?
<equwal> I'm still working on defmacro/g!
<no-defun-allowed> (defmacro brainfuck (code) `(lambda () (brainfuck-interpret ,(symbol-name code)))
<no-defun-allowed> only downside of that is it interns the code
<equwal> I got it working like this: #defmacro/g! name (z) `(let ((,g!y ,z)) (list ,g!y ,g!y))
fikka has joined #lisp
arescorpio has joined #lisp
<equwal> It does parentheses by just counting until there is an extra one on the right. I am trying to set it up such that it can be called with (defmacro/g!...) making #\d the macro-character. Unfortunately I can't do it without making it impossible to defun declare, etc.
<Bike> yep.
Mr-Potter has quit [Quit: Leaving]
<equwal> Just impossible?
<Bike> putting a reader macro on d means when the reader sees a d, you take over parsing. you can't just do it halfway.
<equwal> So I need to reimplement the whole reader.
<Bike> if i were you, i'd use a special reader macro for the body instead.
<equwal> how so?
<Bike> so you do something like (defmacro/g! name params #`(... ,g!z ...))
<equwal> Well I could do that, but I was hoping to get it semantically the same as the book so I could send it to the production code repo.
<equwal> Which means it needs to be a fake function.
fikka has quit [Ping timeout: 240 seconds]
<equwal> I wonder if the SBCL reader has hooks I can hack into?
<Bike> there is no such thing as a fake function. i'm not sure where you got the idea that there was.
<Bike> the sbcl reader has hooks in the form of reader macros.
<equwal> I could get it to work if, for example, I set the reader to activate a reader macro if it reads "DEFMACRO/G!"
<Bike> right, you cannot do that, and sbcl does not have hooks for that.
<Bike> as an example, if you had '(defmacro/g! ...), with your scheme funny things would happen.
<equwal> Well it is true you wouldn't be able to define defmacro! on top of it, for example.
d4ryus has quit [Ping timeout: 240 seconds]
<no-defun-allowed> all i can suggest is to write a macro that takes the code as an argument, takes the SYMBOL-NAME of the symbol and uninterns it
<equwal> I don't understand.
<equwal> What symbol gets uninterned?
<no-defun-allowed> your brainfuck code
<no-defun-allowed> not a reader macro, just a normal macro which reads in your code as an an argument, eg (brainfuck [+.>])
<equwal> Oh right yes.
<Bike> clever, but doesn't seem helpful for the actual g! problem.
<equwal> I used the brainfuck because I though I was simplifying my question. I don't see why what I want to do should be impossible. I think I can do it if I save the original readtable and access it before reverting and the closing parenthesis.
<Bike> maybe. that's just, likke, kind of overcomplicated.
<Bike> you're basically fighting the language here.
<equwal> W
<no-defun-allowed> yeah, i don't think that's the right approach
<no-defun-allowed> if you want to do a readtable thing, #f[code goes here] could work better for syntax i think
<equwal> ok.
<no-defun-allowed> i think #f isn't taken...
<equwal> It isn't I use it.
<no-defun-allowed> what's it do then? don't remember that one
<equwal> I mean it isn't taken, I use it for my brainfuck code.
<no-defun-allowed> ah ok
nicdev has quit [Ping timeout: 240 seconds]
<didi> I never used a read macro, but luv-slides has one that I might try some day: #L(if (oddp _) (* _ _) 0) -> (lambda (_) (if (oddp _) (* _ _) 0))
fikka has joined #lisp
neosloth has quit [Remote host closed the connection]
fikka has quit [Ping timeout: 252 seconds]
troydm has quit [Quit: What is Hope? That all of your wishes and all of your dreams come true? To turn back time because things were not supposed to happen like that (C) Rau Le Creuset]
troydm has joined #lisp
nicdev has joined #lisp
fikka has joined #lisp
<didi> Argh. Format's call function directive is not too hot; I've to use colons to call functions from packages, even if it's a symbol interned in the same package I'm in.
fikka has quit [Ping timeout: 245 seconds]
<didi> Any clever way to turn a cons into a list?
<didi> Better than (destructuring-bing (a . b) cons (list a b)).
robotoad has quit [Ping timeout: 244 seconds]
arescorpio has quit [Ping timeout: 240 seconds]
<aeth> didi: That seems like the best way
<aeth> well, bind. I'm not a big fan of Bing.
<didi> aeth: ;-)
<didi> Thank you.
<aeth> Any list/cons processing should directly or indirectly use destructuring-bind unless there's a built-in to handle it directly imo. Probably slows it down a bit but makes sure it is what you think it is.
<aeth> Otherwise you can have things like an invalid tail, or an implicit NIL, etc.
<aeth> (and if you actually don't care about the tail in a destructuring-bind it's not hard to do an ignored &rest rest)
<aeth> In this particular case, most alternatives would probably work on NIL because (car nil) is NIL and (cdr nil) is NIL.
fikka has joined #lisp
robotoad has joined #lisp
<didi> Silly format. If I didn't like you so much...
fikka has quit [Ping timeout: 268 seconds]
fikka has joined #lisp
<drmeister> Is there any way to force the printing of package names with symbols?
robotoad has quit [Quit: robotoad]
fikka has quit [Ping timeout: 245 seconds]
equwal has quit [Remote host closed the connection]
equwal has joined #lisp
<drmeister> Bind the *package* to (find-package "KEYWORD")
dddddd has quit [Remote host closed the connection]
_whitelogger has joined #lisp
fikka has joined #lisp
orivej has quit [Ping timeout: 240 seconds]
robotoad has joined #lisp
fikka has quit [Ping timeout: 245 seconds]
arescorpio has joined #lisp
arescorpio has quit [Max SendQ exceeded]
reverse_light has quit [Ping timeout: 246 seconds]
arescorpio has joined #lisp
mejja has quit [Quit: mejja]
fikka has joined #lisp
fikka has quit [Ping timeout: 272 seconds]
arescorpio has quit [Remote host closed the connection]
fikka has joined #lisp
<beach> Good morning everyone!
fikka has quit [Ping timeout: 272 seconds]
fikka has joined #lisp
nicdev has quit [Quit: ERC (IRC client for Emacs 26.1)]
fikka has quit [Ping timeout: 245 seconds]
<fiddlerwoaroof> morning beach
smokeink has joined #lisp
<fiddlerwoaroof> elderK, equwal: LoL is a bit problematic because it doesn't restrict its macro definitions to things that are standards-compliant.
<fiddlerwoaroof> So, in some cases, you might discover that implementations have implemented things in a way that breaks the examples.
nicdev has joined #lisp
<fiddlerwoaroof> But, I learned the useful trick of expanding to a MACROLET in situations where one might otherwise try to write a codewalker from it.
_whitelogger has joined #lisp
fikka has quit [Ping timeout: 268 seconds]
_whitelogger has joined #lisp
dale has joined #lisp
fikka has joined #lisp
ggole has joined #lisp
fikka has quit [Ping timeout: 244 seconds]
buffergn0me has quit [Ping timeout: 250 seconds]
fikka has joined #lisp
rumbler31 has joined #lisp
rumbler31 has quit [Remote host closed the connection]
rumbler31 has joined #lisp
fikka has quit [Ping timeout: 246 seconds]
irdr has quit [Remote host closed the connection]
irdr has joined #lisp
fikka has joined #lisp
shifty has joined #lisp
equwal has quit [Ping timeout: 268 seconds]
fikka has quit [Ping timeout: 272 seconds]
WhoTookMyName has joined #lisp
<LdBeth> Weird, seems there are at least three different versions of Flavors
_whitelogger has joined #lisp
fikka has quit [Ping timeout: 244 seconds]
angavrilov has joined #lisp
<holycow> l
<holycow> sorry, typo
xkapastel has quit [Quit: Connection closed for inactivity]
fikka has joined #lisp
rippa has joined #lisp
fikka has quit [Ping timeout: 246 seconds]
rumbler31 has quit [Remote host closed the connection]
fikka has joined #lisp
fikka has quit [Ping timeout: 268 seconds]
_whitelogger has joined #lisp
ryan_vw has quit [Ping timeout: 240 seconds]
fikka has joined #lisp
matzy_ has quit [Ping timeout: 252 seconds]
fikka has quit [Ping timeout: 268 seconds]
razzy has quit [Ping timeout: 246 seconds]
dale has quit [Quit: dale]
makomo has joined #lisp
fikka has joined #lisp
fikka has quit [Ping timeout: 268 seconds]
<beach> Not quite done, but nearly so: http://metamodular.com/bootstrapping.pdf
<beach> Needs conclusions and some figures.
vlatkoB has joined #lisp
<LdBeth> Does anyone know what does defobfun in MCL do?
<makomo> morning
<LdBeth> Ah, seems it's a legacy form of defmethod
<LdBeth> makomo: morning
<beach> Hello makomo.
sigjuice has quit [Ping timeout: 240 seconds]
sigjuice has joined #lisp
joast has quit [Ping timeout: 240 seconds]
razzy has joined #lisp
orivej has joined #lisp
shka_ has joined #lisp
fikka has joined #lisp
fikka has quit [Ping timeout: 272 seconds]
another-user has joined #lisp
<another-user> hi
nirved has joined #lisp
<beach> Hello another-user.
<another-user> is there some kind of "rule of thumb" for when to use defstruct vs defclass?
<beach> Yes.
<beach> Always use DEFCLASS.
<another-user> beach: got it, thank you!
<beach> I should moderate that a bit...
<beach> IF you know what you are doing, IF you have extreme performance requirements, IF you know that your implementation generates faster code for structs, IF your application is know to spend a significant amount of time accessing object slots, and IF you are willing to live with the semantics of structs, then you should use them.
<Inline> with which implementation is that the case ?
<beach> Is what the case?
<beach> That struct access is faster?
<Inline> yes
<beach> Most existing implementations.
<beach> The struct semantics were specified so that no indirection is needed.
<beach> Not so for standard objects.
<another-user> beach: i see, this is great explanation
<beach> Also, slot accessors for structs are ordinary functions, and if your implementation is slower on calling a generic function, that will make structs faster as well.
fikka has joined #lisp
<Inline> that all sounds like inviting into structs first, try out a few oop with structs and then later on try to switch onto clos....
<beach> Now, like I said yesterday in #clschool, I often see people using structs for better performance, but then they are totally incompetent when it comes to designing efficient data structures and algorithms. It would be much better to do it the other way around.
<Inline> hmmmm
<beach> Inline: Why do you say that? I would think the other way around. Premature optimization and all.
<Inline> no idea, to get a feel for oop or so
<beach> Structs really mess up the development process, so you would want them in the end, if at all.
<beach> Er, what?
<Inline> oop design i mean
<beach> Using standard classes is much more OOP than using structs.
<Inline> that's not what i meant
<another-user> beach: i have also implemented example you gave me(optimization without breaking interface) and i was really impressed!
<no-defun-allowed> structs are basically the C structs, they're a bunch of values stuck together
<beach> another-user: Great.
<beach> Inline: What did you mean then?
<no-defun-allowed> a standard-instance has superclasses, subclasses, and all the OOP stuff going for it
graftin` has joined #lisp
<beach> Inline: By the way, you can't "switch into CLOS" because CLOS is already present. STRUCTURE-OBJECT and STRUCTURE-CLASS are perfectly good classes.
<beach> Every Common Lisp datum is the instance of some class.
fikka has quit [Ping timeout: 246 seconds]
<Inline> what's up with https://www-fourier.ujf-grenoble.fr ?
<Inline> does that fail for you too ?
rumbler31 has joined #lisp
<Inline> i get timeouts
<Inline> wth
rumbler31 has quit [Ping timeout: 240 seconds]
<jcowan> Henry Baker very much preferred structures to classes (maybe still does, I don't know)
<jackdaniel> structures conceptually are much simplier, I can imagine why he preferred them in his theoretical works
<beach> jcowan: Structs are classes too.
fikka has joined #lisp
<jackdaniel> I'm certain that everyone talking about classes in Common Lisp means standard-class (and not i.e builtin-class or a metaclass of some kind)
<beach> Yes, and that's a bad idea, because it is not the correct terminology.
<jackdaniel> s/everyone/everyone in above discussion/ I can imagine someone talking about clases in general of course
<beach> So I am trying to fix it.
<shka_> good morning
<no-defun-allowed> morning shka_
<makomo> shka_: morning
pjb has joined #lisp
<beach> Inline: So when you say "that all sounds like inviting into structs first", either you don't buy my advice, or else it means that you initially assume that you know what you are doing, that you have extreme performance requirements, that you know that your implementation generates faster code for structs, that your application will spend a significant amount of time accessing object slots, and that you are willing to live with the
<beach> semantics of structs.
<beach> If that's not a very good example of "premature optimization" I don't know what is.
<pjb> well, one advantage of defstruct is that it's more concise than defclass. (defstruct pt x y) and you're set.
<beach> Good, let's all convert to DEFSTRUCT. I should go rewrite Cleavir right away.
<jackdaniel> nb: define-class in ergolib gives you similar concise syntax for standard classes
<pjb> Nope.
fikka has quit [Ping timeout: 246 seconds]
<pjb> Use a macro with the simple syntax that expand to defclass etc.
<pjb> like define-class.
iAmDecim has joined #lisp
<pjb> The only serious problem you may have with defstruct is that the readers and writers it generates are not (necessarily) generic functions.
<no-defun-allowed> the #1 draw for defstruct for me is that it's less typing cause of the implicit accessors, which is really stupid come to think of it
<pjb> But classes have so many advantages. You can use change-class, you can have multiple-inheritance, you can introspect the slots with the MOP, you can add slots at run-time…
<pjb> But structs can use vector or lists are storage, and you still have inheriting with :include >:-}
<jackdaniel> no-defun-allowed: while it is OK to be suspicious about macros which define functions on your behalf I don't know how this is stupid - could you elaborate?
<no-defun-allowed> that the only reason to use defstruct early in development is that it's less typing
<jackdaniel> less typing also means less reading
<jackdaniel> more concise syntax carries more information per line for the code reader
<jackdaniel> that is a desireable quality (and if you ask me - far from stupid)
<jackdaniel> that's why we abstract many things with new words: you say "computer", not "an electronical circuit with a program which …"
<pjb> Anyways, in an application, you often will write special macros to define entities of your application, that expand into a defclass and more, so you won't have to write all the verbosity of defclass yourself anyways.
<no-defun-allowed> yes, maybe a simpler macro that expanded to defclass would be more reasonably
<jackdaniel> that said I don't think defclass is too verbose
<no-defun-allowed> it's not awful but it's not short enough for lazy people
<beach> I submitted this idea in #sicl, but there was no reaction: What if the :TYPE option of a slot that mentions a class could result in a slot writer method that specialized on both its parameters?
<pjb> beach: :type, not :class.
<beach> I did write :TYPE.
<pjb> Furthermoree, that doesn't prevent the existance of other writers with other classes for the value, so you won't get an error. Also you'd get a missing method error, instead of a type error.
<pjb> Yes, :type let you specify a type, but methods disptch on classes.
<no-defun-allowed> so if you had a :type of FOO in BAR for the slot BAZ it'd generate the equivalent of (defmethod bar-baz ((bar bar) (baz foo)))?
<beach> I did write ":TYPE that mentions a class"
<pjb> Oh, right.
<pjb> In that case, remains the error you'd get. NO-APPLICABLE-METHOD vs. TYPE-ERROR.
<beach> no-defun-allowed: That's the idea, yes, except it would be (defmethod (setf BAZ) ((new-value FOO) (object BAR)) ...)
<no-defun-allowed> oh, of course.
<beach> pjb: Indeed.
<pjb> beach: actually, the point is that I feel uneasy with it, because I'm not sure there wouldn't be case where the semantics would change. We could know if we had a formal semantic definition of the language, and check the equations…
<beach> Would this behavior be conforming?
<no-defun-allowed> i like it, sounds good, but i think a second one would also be needed to handle type-errors presumably
<beach> pjb: That's why I am asking, yes.
<no-defun-allowed> strangely enough, both SBCL and CLISP allow me to create an instance of a class where the slot type requirement is violated
<pjb> I may have written such setter method by hand, so I'm not entire against the idea. Perhaps it would enter into the generalization category, so it'd be acceptable. It would allow us to write additionnal methods for other classes of value.
<no-defun-allowed> i did (defclass a () ((b :initarg :value :type integer))) and (make-instance 'a :value :foo) and it still made the instance
<jackdaniel> no-defun-allowed: standard doesn't say, that implementation has to enforce such type, it is just an annotation
<jackdaniel> that said, sbcl and ccl check the type on high safety settings
<beach> no-defun-allowed: If you put high values of DEBUG etc, it will check.
<no-defun-allowed> i see then
<pjb> clhs defclass doesn't say anything about the specialization of the method.
<beach> Interesting.
<no-defun-allowed> well, go for it beach, i don't see why it wouldn't be a good idea then
<pjb> Only that it should be unqualified, so no :before :around :after <--.
<beach> Right.
<jackdaniel> so in that case bahavior will be different if you supply class name as a type and if you supply another type. I wonder how much it could bite a programmer
<beach> Good question. That's why I submitted the idea here, so that people could help me think about it.
<jackdaniel> I don't know how much code out there depends on type-error being signalled on such setf (given standard does not mandate such error)
<jackdaniel> but if there is such code, then handling of such conditions will break inconsistently
<pjb> Well, the first difference would be that you'd have a method more specialized than expected. So some program could have other methods, with a more general class, a more specific class or with the same class, that would override the defclass provided method.
<pjb> You would need to still provide the method on T, so that user supplied method with a more general class could still call-next-method. They'd be shadowed by your method for values of the correct class, but not for values of superclasses.
<pjb> or different classes.
<beach> pjb: Very good point.
<pjb> So the question is how many program include such additionnal methods on writers, and whether we accept to break them, or whether we want to continue support the possibility even if it's (almost) never used.
<beach> jackdaniel: Also a good point.
<jackdaniel> pjb: I think that it is a non-brainer here: if you break conforming programs by some change it shouldn't be included. your example is a conforming use of the mechanism.
<pjb> beach: you may try: grep -RnHi -e 'defmethod.*(setf' ~/quicklisp
<pjb> There's /Users/pjb/quicklisp/local-projects/com/informatimago/pgl/pgl.lisp:2031:(defmethod (setf title) ((title string) (self window))
<jackdaniel> so even if no such code exists yet, such change would render sicl being si-not-quite-cl
<beach> Well, I won't do it. At least not initially. I need more thoughts and more time to think about the consequences.
<pjb> It's about the only case, from a quick overview.
<beach> Good to know.
<pjb> In that case, the slot has only a reader. The writer calls a function that sends message to the remote window managing process.
<beach> Anyway, I should supply the :TYPE anyway. The purpose of my suggestion was to make satiation more reasonable. If I have an unspecialized parameter, satiation will fill the call history will all classes in the system. I wanted to avoid that. But I can use the :TYPE information just for satiation instead.
<pjb> (I've not done a (quick-install-all) on this system, so it's only a partial sondage).
<beach> That should be fun, i.e. rewrite satiation to take into account the :TYPE option of the slots.
<beach> Satiation is free to do what it wants as long as the semantics are preserved. If it misses something, the only thing that happens is that the generic function will be updated when it is called with a type that satiation missed.
<beach> The purpose is to avoid that (say) COMPUTE-DISCRIMINATING-FUNCTION is called with itself as an argument. So the call history of that function needs to include an entry for standard generic functions.
<elderK> Hey all.
<beach> Hello elderK.
<elderK> Man, I'm not having much luck figuring out nested-backquoting and stuff :(
<elderK> I thought I was but noooope.
<beach> But during bootstrapping, I need to make sure that all the accessors are satiated before I can "tie the knot".
<elderK> Innermost BQ expanded first, leftmost comma belongs to innermost...
* beach is suddenly not sure that his last statement is true. Goes to think...
<jackdaniel> elderK: three steps of enlightnment: novice uses only single backquote, student uses nested backquotes, master uses only single backquote
<jackdaniel> skip the middle and jump to mastery=
<jackdaniel> =)
<elderK> :) Aye. Still, I want to understand :)
<elderK> I tried to write my own once-only. I failed. I know what I want to do, and what has to be done. Just not how to actually code it.
<elderK> So, I looked at PCL - but it wasn't very forthcoming with nested stuff.
<elderK> Have been bouncing between CLHS and CLtL2 now
<makomo> elderK: yeah, the definition in PCL is really horrible :-)
<makomo> the one i linked (from Alexandria) is much nicer
cage_ has joined #lisp
<elderK> makomo: I mean, PCL doesn't even touch on nesting, not realy.
<makomo> yeah, it doesn't
<jackdaniel> "On Lisp" by Paul Graham has an insightful description of once-only
<jackdaniel> (afair)
<makomo> elderK: one thing -- there's a difference between "expanded" and "evaluated"
<makomo> when the CLHS says "expanded", it's referring to the process of reading in the backquote and processing it as a reader macro, i.e. "expanding it into some implementation-defined form"
<makomo> once you read in the nested backquote template, *then* it's time to (iteratively) evaluate it
<makomo> so when the CLHS says "the innermost backquote should be expanded first", it's referring to the process of converting the reader macro into an implementation-defined form
<makomo> it's not saying "innermost backquotes are evaluated first"
<makomo> evaluating proceeds in a top-bottom fashion
<makomo> evaluation*
<jackdaniel> I don't understand this description :(
<elderK> Ah, thank you
<makomo> (that particular usage of "expand" was the most troublesome thing regarding the CLHS specification of backquote (for me at least), as it's not explained explictily anywhere)
<elderK> Yeah, that confused the shit out of me.
<makomo> yup, that one sentence is really horrible :-)
<elderK> I was thinking like, `(stuff `(more stuff)) that it meant it would go through `(stuff EXPANDED) then FULL_EXPANSION
d4ryus has joined #lisp
<makomo> jackdaniel: which one?
<elderK> Also, irccloud seems to treat ` specially.
<makomo> elderK: use https://plaster.tymoon.eu
<pjb> elderK: ` without any , or ,@ is equivalent to '
<elderK> Yup.
<pjb> so `(stuff `(more stuff)) = '(stuff '(more stuf)) = (quote (stuff (quote (more stuff))))
<makomo> elderK: another note -- if you ever decide to do the expansion yourself (i.e. follow the formal rules in CLHS by hand), i would suggest you do the expansion "iteratively" (in multiple passes)
<jackdaniel> makomo: yours, about expanding and evaluating
<makomo> elderK: the algorithm of course works recursively, but it's really impossible for a human to keep track of the various "stack frames"
<makomo> so you process the expansion in passes (steps), applying the rules until you get rid of the innermost backquote template
<makomo> then you start applying them to get rid of the innermost-1 backquote, etc.
<elderK> Does it expand kind of like... peeling an onion?
<makomo> jackdaniel: hmm, what's confusing?
<pjb> Well, or not. You don't need to resolve all the backquotes. Only the one you're currently evaluating.
<jackdaniel> makomo: erm, description
<makomo> jackdaniel: i mean, any particular part or? :-)
<jackdaniel> ... so .. then .. but .. so ..
<makomo> elderK: well kinda, except that the inner layers are peeled before the outer ones :D
<jackdaniel> whole construction, but nvm, since elderK understood it's fine, I was not an audience anyway
<jackdaniel> s/it's/it it's/
<makomo> jackdaniel: i don't mind clarifying. we were referring to this line in CLHS 2.4.6 " If the backquote syntax is nested, the innermost backquoted form should be expanded first. This means that if several commas occur in a row, the leftmost one belongs to the innermost backquote. "
<makomo> "expanded" here means "processed at read-time". it's not referring to the evaluation of the form
<elderK> :( Still confused.
<jackdaniel> I'm aware how backquote works, I've just pointed out that your explanation was confusing to me
<elderK> You guys are helping but still kind of confused.
<makomo> jackdaniel: ah, ok
<elderK> Like, I get that `(...... `(....)) is expanded into some form by CL, maybe it says (quasiquote ..... `(...)) then (quasiquote .... (quasiquote ...))
<elderK> And then I guess it gets to actually filling the "templates" as it were.
<elderK> Which, goes from inside-out, right?
<elderK> So the "nested quasiquote" is... uh, evaluated? (expanded?) first.
<jackdaniel> backqoute isn't an operator (or at least doesn't have to be)
<makomo> elderK: the expansion proceeds bottom-top (innermost-to-outermost) which is important because that defines the association between a comma and a backquote -- the rightmost comma corresponds to the outermost backquote
<makomo> elderK: the filling of the template happens at evaluation. evaluation proceeds top-bottom (outermost-to-innermost)
<makomo> to evaluate a backquote template means to interpolate/splice in all the results of forms that have been marked with , or ,@ that *correspond to the outermost backquote*
<jackdaniel> elderK: it goes from the outside so to speak
<elderK> I guess I'm confused with expansion vs evaluation then
<jackdaniel> please try this out
<jackdaniel> (defmacro foo ()
<jackdaniel> `(progn ,(progn (print "HI! outermost"))
<jackdaniel> `(progn ,(print "HI! innermost") ,,(print "HI! outermost"))))
<jackdaniel> and then (foo)
<jackdaniel> I'm out to eat something, see you
<elderK> Seeya jackdaniel
<elderK> Well, reading that, I'd assume Hi Outermost would print twice?
<makomo> elderK:
<makomo> (let ((c1 'c2)
<makomo> (c2 'c3)
<makomo> (c3 'c4)
<makomo> (c4 1))
<makomo> ````,,,,c1)
<makomo> try this out :-)
<pjb> So, the problem is that it's difficult to see it step by step, because since backquote is a reader macro, all the levels of backquoting are resolved and transformed in to list expressions when read.
<pjb> makomo: honestly, it'd be easier if it was on a single line!
<pjb> How do you expect us to copy and paste that?
<elderK> No, it's better on multiple lines.
<makomo> pjb: eh, yeah :-)
<elderK> At least for /reading/
<elderK> Would it return c2?
<pjb> But the point is not to read, it's to try it out in the repl!
<makomo> elderK: it would return ```,,,c2
<makomo> you eval that again!
<makomo> (but you'll have to manually paste the result into that let and evaluate it again)
<pjb> Here it returns c2.
<pjb> and says the other variables are unused.
<elderK> I get ```,,,c2
<makomo> i couldn't use (eval (eval (eval (eval '````,,,,c4)))) as i would lose the lexical environment (that's the behavior of EVAL) (i.e. EVAL wouldn't see the lexical bindings of the LET)
<elderK> So, the "innermost" `, is stripped?
<elderK> Or rather, `,,,,c1 expands to ,,,c1
<makomo> the outermost ` and the innermost ,!
<elderK> Outermost meaning leftmost or rightmost?
<makomo> outermost ` meaning the leftmost `, and the innermost , meaning the rightmost ,
<elderK> Okay, so if I want to write it differently, XYZWwzyxc1
<pjb> all implementations return c2, only sbcl return ```,,,c2
<makomo> errr, that's a bit confusing, i should keep the two in sync
<makomo> the outermost backquote/comma pair is stripped!*
<makomo> which means: the leftmost backquote, the rightmost comma
puchacz has joined #lisp
<puchacz> hi, for "flattening" list of lists, is this O(n) ?
<puchacz> (apply #'append '((12 3) (8 17) (3)))
<puchacz> I know (reduce #'append '((12 3) (8 17) (3))) is not O(n)
<makomo> elderK: this version will allow you to iteratively do (eval *) at the REPL
<makomo> (let ((c1 'c2))
<makomo> `(let ((c2 'c3))
<makomo> `(let ((c3 'c4))
<makomo> `(let ((c4 '1))
<makomo> `,,,,c1))))
<makomo> which might be a bit more convenient
<no-defun-allowed> Well, I'd presume O(n^2) cause you have one loop over append which loops.
<puchacz> no-defun-allowed: so to have O(n) flatten, I guess I need to write it myself, do I?
<no-defun-allowed> You could condense it onto one like, I don't think the repl will mind.
<no-defun-allowed> If you can make that O(n) without changing data structures, you're a god amongst programmers.
<makomo> no-defun-allowed: yeah of course, but it's easier to read (not to copy paste though) :-)
<no-defun-allowed> If you can get the last cons in O(1) and don't mind destructively modifying the inputs, you can make it O(n).
<makomo> no-defun-allowed: but it makes it clearer to see what i was trying to say (rather than the person on the other side having to untangle the one liner)
<no-defun-allowed> makomo: fair enough.
<elderK> Thank you makomo. I /think/ I'm starting to understand a little. *I think*
<elderK> no-defun-allowed: The many-lines-of-code thing is for me, because I don't run IRC in Emacs.
<elderK> Or Emacs at all.
<elderK> :( I tried to set up Spacemacs but had issues. Not with Spacemacs itself, mind you.
<elderK> Because I had to make an Emacs port, which requires libraries that refuse to cooperate.
<makomo> i don't run IRC in Emacs either
<elderK> But that's an entirely different rant.
<elderK> What IRC client do you use, makomo?
<makomo> elderK: are you on BSD or something?
<makomo> elderK: Weechat
<elderK> Crux
<elderK> One problem is that libjpeg-turbo is built using CMake, which of course, doesn't install .la files. Where as libgd is built with autotools, and expects .la for llibjpeg. Which doesn't exist. So it dies.
<makomo> first time i hear of that distro
<elderK> Emacs requires m17n-lib, which requires gd. ETc, etc.
<elderK> Another alternative is to replace the distribution's libgd with my own version, that uses cmake instead of autotools. But then I'm concerned what other packages it will break.
<elderK> What other things expect say, libgd.la or whatever.
<elderK> It's a real cluster@!#$. Especially since some projects have /two/ build systems. And they don't install the same stuff.
<elderK> SDL has this issue, too.
<makomo> good old software packaging/distribution issues, never to be resolved :-)
<elderK> I really could rant about this for awhile.
<elderK> :P
<elderK> It's like, why not standardize completely around pkg-config? That could help but CMake doesn't want to. And pkg-config is useless on Windows, for the most part.
<elderK> And yeah, never to be resolved is right :P
varjag has joined #lisp
<elderK> makomo: Also, how do you copy individual lines out of Weechat, to your REPL?
<elderK> My urxvt setup is pretty stock - that may be why things like URIs and stuff aren't properly highlighted. At least, not across multiple terminal lines.
<makomo> elderK: that's one of the backquote-related SO Q&As i have bookmarked :-), but only for "archiving" purposes (i.e. i didn't want to link it because i forgot what explanation was offered there)
random-nick has joined #lisp
<makomo> elderK: i use the mouse to select the lines, copy and paste them into emacs and then trim the username/timestamp prefixes
<makomo> not very efficient, but i'm too lazy to automate it somehow
<elderK> Paste with middle-mouse?
<makomo> i use p or ctrl+r
cpt_nemo has quit [Read error: Connection reset by peer]
<makomo> elderK: that answer is okay i think, but you have to follow the poster's terminology
<makomo> "... and that for a doubly nested backquote form, I should reinterpret the innermost backquote forms before reinterpreting the outermost backquote form."
<makomo> "reinterpret" here is our "expand" from before (the "expand" that appears in CLHS)
<makomo> hm, this is actually a very nice answer i think, i like it.
robdog_ has joined #lisp
<makomo> (it's only now that i've read it fully)
<elderK> I'm just trying to "expand" ````,,,,c1
Zaab1t has joined #lisp
<elderK> `,form is the same as form
<elderK> `basic == 'basic
<elderK> hmmm
<elderK> "The innermost is expanded first", so `,,,,c1 is "expanded"
<elderK> Which I'm not sure how to do :D
<elderK> `,,,,c1 is the same as ,,,c1
<elderK> ?
<makomo> `,,,,c1 is invalid, as you have more commas than there are backquotes
<makomo> to understand what "to expand" means, try this
<makomo> (setf *print-pretty* nil)
<makomo> and type this at the repl '````,,,,c4
<makomo> you could also use (read-from-string "````,,,,c4")
<makomo> see how the backquote syntax is expanded into some implementation-defined form? that's what "expansion" is referring to
<makomo> it's a read-time thing
<elderK> No effect.
iAmDecim has quit [Quit: WeeChat 1.9]
<elderK> NM. I thought *print-pretty* was special
<elderK> Right, so thinking the Schemey way: ````,,,,c1 == (quasiquote (quasiquote (quasiquote (quasiquote (unquote (unquote (unquote (unquote c1)))))))) no?
<makomo> (let ((*print-pretty nil)) <form>) won't work at the REPL as the printing of the result happens *after* <form> is evaluated (i.e. outside the LET block, somewhere within SLIME/SWANK)
<makomo> elderK: right
<elderK> So, then the (unquote c1) is "evaluated?" Which will give us whatever c1 is, right?
<elderK> In your example, c2
<makomo> yup
<elderK> I find the ordering so strange.
<elderK> Like, you'd think the innermost quasiquote would cancel the outmost unquote.
<elderK> Rather than c1 being unquoted first
<makomo> it might seem strange, but it makes sense when you think of it as "ladders" (i've heard the term "ladder algorithm" used somewhere)
<makomo> every backquote is a level up, every comma is a level down, so to speak
<makomo> you start at level 0 and only stuff at level 0 gets evaluated
<makomo> or we could use 1-based indices and s/level 0/level 1/
<pjb> elderK: why don't you just read the rules in clhs? They're very clear on how to interpret backquote…
<makomo> elderK: using the SO terminology from that answers, CLHS uses an "equivalency description" -- it describes a possible set of forms that backquote might expand into and derives the evaluation semantics from that
<makomo> that's all fine, but it's useful to know the "replacement description" as well -- an intuitive way to think about "canceling" the various backquote/comma pairs
<beach> Do we agree that the :TYPE slot option is not evaluated?
<makomo> the "replacement description" is simple for simple cases, but needs to be made more complicated (or special cased somewhere) for cases like ,@,@ or ,,@, etc.
<makomo> the "equivalency description" of course has no problem with those
<pjb> beach: indeed, you don't quote the type specifier.
<makomo> pjb: was meant for you ^, not elderK (sorry)
sonologico has joined #lisp
<makomo> using the terminology from that SO answer*
<pjb> No way to write (defparameter *my-type* 'integer) (defclass foo ((x :type *my-type*)))
<pjb> beach: instead, (deftype my-type () 'integer) (defclass foo ((x :type my-type)))
<Bike> beach: like in defstruct and defclass? it's not evalauted
<elderK> pjb: I have been. They are not super clear to me yet.
<beach> Thanks!
<jackdaniel> elderK: I think that this topic requires silent contemplation with a single source of information (in this case clhs) instead of multiple ones
<jackdaniel> it is easy to get confused, ie some people put their "intuitive" interpretation into play which may be incorrect (or may not match your mental model)
<elderK> jackdaniel: I would ordinarily agree. But there were parts in the CLHS spec I was not sure how to... apply. Seeing that post on SO, clarifies that.
<elderK> My goal now is to get a few nested macros, and expand them, according to CLHs rules.
<elderK> Perhaps once-only from PCL
<elderK> Then I guess I'll try and get Emacs running again :)
lavaflow has quit [Read error: No route to host]
<makomo> jackdaniel: "silent contemplation" is the part i agree with, but i think you really do need multiple source of information (either to see where they went wrong, or to clarify some points)
<makomo> sources*
lavaflow has joined #lisp
<makomo> elderK: i have a few expansions i did by hand if you'd like to take a look
<elderK> I'd definitely appreciate that.
<jackdaniel> I think that you confuse him instead of helping (and I judge it by the fact, that I was away for more than an hour and you still talk about the same thing)
<elderK> jackdaniel: That's not fair. makomo is actually helping.
<makomo> jackdaniel: confusion is a necessary evil :-)
<elderK> At least, I've found him to be helpful.
<makomo> :-)
<jackdaniel> I'm known for being unfair, sometimes it happens though that being unfair doesn't mean "wrong"
<elderK> :P Also, don't discount the fact that I may be dense.
<elderK> :P
<elderK> Maybe this really is something that's simple. Just, it's not clicking for me atm. But, I am definitely closer now.
<jackdaniel> also being satisfied with help and getting grasp of something are two different things as well
<elderK> Agreed.
<jackdaniel> http://ep.yimg.com/ty/cdn/paulgraham/onlisp.pdf here you have nice explanation in english about backquote
<jackdaniel> start from page 82
<jackdaniel> chapter 16 gives you more examples with nested backquotes
sonologico has left #lisp ["Leaving"]
varjag has quit [Ping timeout: 252 seconds]
<makomo> elderK: 5 examples in total, don't get scared :-) http://plaster.tymoon.eu/view/1008#1008
<jackdaniel> so called ,@,@ "idiom" is incorrect in light of clhs (it relies on some intuition shared by some)
<makomo> jackdaniel: i proved that incorrect last time we talked about that
<jackdaniel> no you didn't, one of key arguments is that it is "natural extrapolation" from the spec
<jackdaniel> and I was not interested in discussing it, just given you resources you may follow
Guest24308 has quit [Ping timeout: 252 seconds]
<makomo> jackdaniel: it's not an extrapolation, it's ridigly and mechanicaly following the rules
<makomo> which is why i suggested that elderK read and try to follow the rules by hand
<jackdaniel> and again, I'm not interested in discussing it. still, it is incorrect "idiom".
<makomo> ah well...
<makomo> why even mention it if you're not willing to discuss it fully :/
<pjb> it's a reference, check the logs.
<jackdaniel> I'm just trying to prevent you from teaching elderK something incorrect
<makomo> jackdaniel: when you get the time, take a look at the expansion i did by hand and tell me what step is wrong
<makomo> right, but you're not providing any proof that it is undefined/incorrect as per the CLHS rules
<jackdaniel> I have more interesting thigns to do than proving you wrong. I did point you to the references which discuss it
<makomo> yeah, and i've read that reference, which is actually a bug report
<makomo> but none of the commenters there use the formal rules to prove that ,@,@ is undefined, which is why i did it by myself
<elderK> Thank you, makomo.
<jackdaniel> if this is not enough for you, then please consider practical argument for not spreading this incorrect information: it doesn't work on all CL implementations
<elderK> This is /super/ helpful.
<elderK> Thank you for showing the explicit steps.
<makomo> jackdaniel: that's an implementation's problem, is it not? pjb actually reported to CCL that ,@,@ doesn't work
heisig has joined #lisp
<jackdaniel> no, this is a community problem that you spread a dubious syntax and you label it "idiomatic"
<jackdaniel> which results in code which is incorrect/doesn't work
<jackdaniel> that's all I have to say on this topic
<makomo> jackdaniel: how is it dubious when it is fully and formally defined by the CLHS?
<jackdaniel> makomo: let's make a wager: I prove you wrong, you solve one ECL issue I point you to, I'm not able to, I'll solve another CL foss issue you point me to
<jackdaniel> hm?
<makomo> jackdaniel: just saying that it's incorrect and leaving isn't helpful... we should sit down and discuss it once and for all some time :-)
<makomo> jackdaniel: haha, let me think about it
rumbler31 has joined #lisp
<pjb> Yes, it's a good idea to wage issues to solve…
<makomo> jackdaniel: hell, why the heck not! (i'd be interested in McCLIM as well)
<makomo> but a necessary condition for the proof is that it has to be done using the formal rules provided by the CLHS, ok?
<pjb> Yes.
<makomo> no bug reports or external discussions are allowed
<pjb> You can have clhs arguments in but reports or external discussions.
<pjb> But indeed, it's the clhs that should be the origin of the reasoning.
<makomo> right, that's what i meant
nicball has joined #lisp
rumbler31 has quit [Ping timeout: 252 seconds]
void_pointer has joined #lisp
<makomo> jackdaniel: so is it a deal then? :-)
varjag has joined #lisp
nicball has quit [Ping timeout: 252 seconds]
nicball has joined #lisp
crsc has quit [Quit: leaving]
nicball has quit [Remote host closed the connection]
lavaflow has quit [Read error: No route to host]
lavaflow has joined #lisp
<elderK> makomo: You treat `'something like ''something. I.e The 'something as a "basic object." Would I be incorrect to expand that further into, `(quote something) ?
<elderK> Wow, irccloud really mutilated that message.
<makomo> elderK: that would be correct and was something i tried once, but found it too verbose
<makomo> but yes, that would be the 100% right way to do it
<elderK> Sweet.
frgo has quit []
<elderK> So, I take it reader macros are expanded first always, right?
<elderK> So if I ahve `(..... 'a)
<elderK> the ` is expanded first.
<elderK> Then all the othe rthings, eventually, I'll have the usual forms, with '
<elderK> Then I expand them to (quote ...)
<pjb> elderK: reader macro read the form!
<void_pointer> elderK: reader macros are expanded when the file is read into lisp, before being evaluated, compiled, or really anything else for that matter
<pjb> ` is read.
<void_pointer> elderK: expanded is not really the right term though, so sorry.
<pjb> elderK: cf chapter 2. The lisp reader reads the character #\` then it looks it up in the *readtable* and find a reader macro for it. It calls the reader macro.
<void_pointer> elderK: what pjb said, they are used to do the actual reading
<elderK> Yes, I know.
<makomo> elderK: the reader would expand 'a somewhere within the algorithm to expand `
scymtym has quit [Ping timeout: 245 seconds]
<makomo> "expand" meaning "read" really
<pjb> elderK: the reader-macro for ` will read the following expressions, parsing the , and ,@ and substiting the whole by a lisp form to build the equivalent list.
<pjb> (let ((bar 42)) '`(foo ,bar)) #| --> (list* 'foo (list bar)) |# <-- This is what is read.
<pjb> (let ((bar 42)) (read-from-string "`(foo ,bar)")) #| --> (list* 'foo (list bar)) ; 11 |#
<jackdaniel> makomo: it mostly is, first we have to point out issues (to avoid situation, where the winner side picks an unreasonable issue)
<pjb> Notice bar is not evaluated into the read form.
<pjb> it's evaluated when the form that has been read is evaluated.
<jackdaniel> I think that fixing it should fit in 20h tops
<makomo> jackdaniel: well, it's not like either of us is *required* to do what the other says, so it's mostly a matter of pride/honor
<jackdaniel> I insist that we first agree to designated issues
<makomo> i was going to trust you to pick out something normal (it's not like i ever worked on either ECL or McCLIM, so it would be a wild ride anyway)
<makomo> sure, but i'm not sure what i could give you
<jackdaniel> so please send me your proof that ,@,@ is correct (expansion you have mentioned which follows rules) and the issue you have picked when you have it
<pjb> That's easy :-)
<makomo> jackdaniel: i've posted it above on plaster, that's the expansion
<jackdaniel> OK
<makomo> jackdaniel: haha i saw that issue yesterday
<jackdaniel> it is the one I've filled recently (yesterday), it should be fairly easy
<makomo> hmm ok
<jackdaniel> you need to verify, if structure layout is the same and provide two restarts if it isn't
<jackdaniel> most effort on your side would be navigating through ecl source code which codebase you are not familiar with
igemnace has joined #lisp
<makomo> jackdaniel: exactly that, yeah
<jackdaniel> I suspect that only Lisp part needs changing
<makomo> jackdaniel: ok, my issue is (half-jokingly) https://web.archive.org/web/20130622010232/http://sourceforge.net/p/ecls/bugs/251/ :-)
<makomo> since if it turns out to be correct, one would like to see it fixed
frgo has joined #lisp
<jackdaniel> OK, but I don't promise that I'll solve it before next release, it will be pretty involving change of the reader which is written in most part in C
<makomo> that's ok :-)
<jackdaniel> I'll let you know when I get to the doulbe splice (I first need to finish current PR on McCLIM)
<makomo> jackdaniel: deal! in the meantime i'll double check my expansion
<jackdaniel> what are the numbers in comments? I gather they are not CLHS rules used?
<makomo> just the individual steps, i haven't documented which particular rule was used, but the steps are small enough so it should be easy to see
razzy has quit [Ping timeout: 252 seconds]
crsc has joined #lisp
<makomo> ah, seems like (4) and (5) are accidentally the same thing, c/p error probably
frgo has quit [Ping timeout: 268 seconds]
Inline has quit [Read error: Connection reset by peer]
Inline has joined #lisp
Inline has quit [Read error: Connection reset by peer]
frgo has joined #lisp
igemnace has quit [Quit: WeeChat 2.3]
<elderK> makomo: How long did it take you before you could follow this process in your head at lightspeed?
<elderK> Or, over time of expanding things this way, you just began to recognize patterns?
scymtym has joined #lisp
<elderK> I've been doing the expansions by hand, on my own, then comparing against your notes.
<elderK> :P I skip the nils a lot
d4ryus has quit [Ping timeout: 252 seconds]
d4ryus has joined #lisp
<makomo> elderK: i'm not sure, but you *do* start to recognize the patterns, trust me
<makomo> Steele mentions it in cltl2 as well (and he has a very nice discussion of backquote there -- that's another resource i would suggest)
<makomo> the rules from the CLHS spec are the ones in cltl2 actually :-)
<makomo> s/spec//
<makomo> elderK:
<makomo> woops
Essadon has joined #lisp
McParen has joined #lisp
dkmueller has joined #lisp
graftin` has quit [Ping timeout: 252 seconds]
Inline has joined #lisp
<makomo> nevermind, steps (4) and (5) in the expansion of ,@,@ do differ, but the difference is a single backquote replaced with a quote
<makomo> i just didn't see it the first time
varjag has quit [Ping timeout: 244 seconds]
varjag has joined #lisp
smokeink has quit [Remote host closed the connection]
<robdog_> serialization question
<robdog_> i know you can use (read on a filehandle/stream to read an sexp
<robdog_> how do you write out the sexp on a variable? ie hash
<robdog_> so i can read it back in with (read
<makomo> PRINT?
Inline has quit [Read error: Connection reset by peer]
Inline has joined #lisp
dkmueller has quit [Quit: Lost terminal]
<robdog_> i wish
<robdog_> i found a list of libraries
<robdog_> so im going to guess its not doable "out of the box"
razzy has joined #lisp
<robdog_> thats the link
<cage_> i used cl-marshal it works for me
<cage_> expecially if you want to de/serialize an instance of a class
shifty has quit [Ping timeout: 252 seconds]
<robdog_> cool..thanks cage_
<cage_> you're welcome! :)
Guest24308 has joined #lisp
varjag has quit [Ping timeout: 252 seconds]
robdog_ has quit [Remote host closed the connection]
esper0s has joined #lisp
beach has quit [Ping timeout: 252 seconds]
varjag has joined #lisp
beach has joined #lisp
varjag has quit [Remote host closed the connection]
varjagg has joined #lisp
warweasle has joined #lisp
maximjaffe has joined #lisp
_whitelogger has joined #lisp
joast has joined #lisp
rumbler31 has joined #lisp
puchacz has quit [Quit: Konversation terminated!]
rumbler31 has quit [Ping timeout: 272 seconds]
kuwze has joined #lisp
rumbler31 has joined #lisp
Mr-Potter has joined #lisp
[1]ringer1 has quit [Read error: Connection reset by peer]
igemnace has joined #lisp
movl has joined #lisp
varjagg is now known as varjag
dddddd has joined #lisp
rumbler31 has quit [Remote host closed the connection]
warweasle has quit [Quit: rcirc on GNU Emacs 24.4.1]
rumbler31 has joined #lisp
scymtym has quit [Remote host closed the connection]
astalla has quit [Ping timeout: 252 seconds]
scymtym has joined #lisp
msb has quit [Ping timeout: 252 seconds]