Xach changed the topic of #commonlisp to: Common Lisp, the #1=(programmable . #1#) programming language | Wiki: <https://www.cliki.net> | IRC Logs: <https://irclog.tymoon.eu/libera/%23commonlisp> | Cookbook: <https://lispcookbook.github.io/cl-cookbook>
CrashTestDummy has joined #commonlisp
taiju has quit [Ping timeout: 260 seconds]
<pjb> CptJimKirk: in a macro you can build a sexp with nothing.
<pjb> CptJimKirk: (mapcar (lambda (maybe-nothing) (append '(some form) maybe-nothing '(other stuff))) '( (#|nothing|#) (some thing))) #| --> ((some form other stuff) (some form some thing other stuff)) |#
recordgroovy has quit [Quit: leaving]
Oladon has quit [Quit: Leaving.]
lottaquestions_ has quit [Quit: Konversation terminated!]
random-nick has quit [Ping timeout: 265 seconds]
nature has quit [Ping timeout: 268 seconds]
lisp123 has joined #commonlisp
<CptJimKirk> saturn2 how is the lisp readtable to work at all when you are expected to set the read table before the invocation of the macro?
<CptJimKirk> oh wait, this is where that let trick comes into play doens't it
nature has joined #commonlisp
selwyn has joined #commonlisp
<CptJimKirk> no that didn't work
<pjb> CptJimKirk: of course, since no reading is done in the dynamic scope!
<CptJimKirk> so then what is it?
<pjb> It is useless to bind dynamic variables if you don't use them while they're bound.
<CptJimKirk> so your'e saying that I would have to define everything that uses this and needs case insensitive symbosl would need to be done inside that let block
<pjb> Also, if you don't mutate the readtable there's no point in copying it.
<CptJimKirk> (setf (readtable-case *readtable*) :preserve)
<CptJimKirk> ?
<pjb> I'm saying that you need to call READ or READ-FROM-STRING.
<pjb> The inner copy-readtable.
<pjb> Your eval is totally bonker too.
<CptJimKirk> is there any way that on the other side of the macro, I can get case insensitivity?
<CptJimKirk> (defmacro defapl (|name| args &rest body)
<CptJimKirk> something like that, or some other thing... that would achieve the case sensitivity I need?
<CptJimKirk> s/insensitive/sensitive/
<pjb> CptJimKirk: april-load is a function-like macro: it has no compilation-time side effect. Therefore there's no point in using it in the topleve of your source file.
<CptJimKirk> I don't want the user to need to know that they should (defapl |fnName| (args) ...)
<pjb> Use (coerce list 'vector) instead of (to-array list).
<CptJimKirk> are "vectors" the same thing as arrays?
<pjb> vector is a subclass of array.
<pjb> (subtypep 'vector 'array) #| --> t ; t |#
<CptJimKirk> but the APL library requires an array argument
<CptJimKirk> if its fully compatible, then ok
lisp123 has quit [Ping timeout: 252 seconds]
<CptJimKirk> but the main thing I'm struggling with the case insensitivy of symbols. Is there any way to achieve the behavior of (defmymacro |caseSensitive| (arg) (etc))
<CptJimKirk> but on the macro side
<CptJimKirk> I basically want exactly a `defun` form but case sensitive and to wrap around April calls
<pjb> of course. Write: (defmymacro |caseSensitive| (arg) (etc))
<CptJimKirk> ... I'm asking for an alternative, not a restatement of the only solution I've found so far
<pjb> You can put this on the first line of your source file: (EVAL-WHEN (:COMPILE-TOPLEVEL :LOAD-TOPLEVEL :EXECUTE) (SETF *READTABLE* (COPY-READTABLE NIL) (READTABLE-CASE *READTABLE*) :PRESERVE))
yitzi has quit [Quit: Leaving]
<pjb> Then your source file becomes case sensitive.
waleee has quit [Ping timeout: 265 seconds]
<pjb> An alternative, but which is less pretty IMO, is to put this: (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil) (readtable-case *readtable*) :invert))
<pjb> In the first case you could write: (DEFMACRO caseSensitive (arg) (IF arg (etc) (whatever)))
<pjb> In the second case, you would write: (defmacro caseSensitive (arg) (if arg (etc) (whatever)))
<CptJimKirk> so the readtable is source-file scoped?
<pjb> But in the second case, (defmacro notlower (arg) (if arg (etc) (whatever))) would define a macro named NOTLOWER, while in the first case, (DEFMACRO yeslower (arg) (IF arg (etc) (whatever))) would define a macro named |yeslower|.
<pjb> CptJimKirk: it is a dynamic binding = it is during some time that it will have its effect. And the time the *readtable* is used, is WHEN you READ stuff. Eg. when you load a file, or when you compile a file. (or when you explicitely call READ or READ-FROM-STRING).
<lotuseater> CptJimKirk: you can extend the reader itself
<CptJimKirk> Well, this is where I'm confused, because I want to be able to define these things interactively in the REPL as you would normally but without breaking the language
<pjb> There's no breaking involved.
<CptJimKirk> if I use preserve case, but I type in lowercased expressions, it can't find normal symbols
<pjb> You can define a function (activate-apl-readtable) that the user can call at the REPL to start typing with APL conventions.
<pjb> CptJimKirk: indeed, You'd have to use uppercase for lisp symbols, since they ARE in uppercase!
<CptJimKirk> no that's not the behavior I'm looking for
<pjb> CptJimKirk: or you can use :invert but it's not pretty.
<CptJimKirk> yuck
<CptJimKirk> So there are some pretty harsh design considerations when messing with symbols
<pjb> (let ((*readtable* (copy-readtable nil))) (setf (readtable-case *readtable*) :invert) (read-from-string "(hello HELLO Hello)")) #| --> (hello |hello| |Hello|) ; 19 |#
<CptJimKirk> but I wouldn't want to write (defun |f| (x) (* x x)) and I don't want to write (defapl |f| (lst) (coerce lst 'vector))
<CptJimKirk> as a famous keyboard enthusiast once said "HHHHHHHHHHHHIDEOUS"
<pjb> CptJimKirk: now, you can define a new symbol with the case changed, but this is not pretty either. But you may like it.
<pjb> (defmacro defapl (name …) (let ((apl-name (intern (string-downcase name) (symbol-package name)))) … `( … ,apl-name) …))
<CptJimKirk> but I can't guarantee that its all lowercase
<pjb> Or you could use the same algorithm as invert.
<lotuseater> when people tell me ridicolous things about "all these parentheses" i like to confuse them that those aren't really there ^^
<pjb> (cond ((not-any (function lower-case-p) (symbol-name name)) (intern (string-downcase name) (symbol-package name))) ((not-any (function upper-case-p) (symbol-name name)) (intern (string-upcase name) (symbol-package name))) (t name))
<CptJimKirk> I'll have to see what that does
nature has quit [Ping timeout: 265 seconds]
<pjb> (mapcar (lambda (name) (cond ((notany (function lower-case-p) (symbol-name name)) (intern (string-downcase name) (symbol-package name))) ((notany (function upper-case-p) (symbol-name name)) (intern (string-upcase name) (symbol-package name))) (t name))) '(foobar |FooBar| |foobar|)) #| --> (|foobar| |FooBar| foobar) |#
<pjb> (mapcar (lambda (name) (cond ((notany (function lower-case-p) (symbol-name name)) (intern (string-downcase name) (symbol-package name))) ((notany (function upper-case-p) (symbol-name name)) (intern (string-upcase name) (symbol-package name))) (t name))) '(foo-bar |Foo-Bar| |foo-bar|)) #| --> (|foo-bar| |Foo-Bar| foo-bar) |#
<pjb> Notice how I have *print-case* #| --> :downcase |#
<pjb> and nothing prevents you to define your macro in lowercase!
<lotuseater> deep dark magic
<saturn2> CptJimKirk: what is the purpose of defapl?
<pjb> (defmacro |defapl| …) so that when you switch to (SETF (READTABLE-CASE *READTABLE*) :PRESERVE), you can write (defapl FooBar …)
<pjb> Why would it be bad if functions defined in lisp were named with uppercase? you could have both f and F in your apl programs, and it would be obvious that F is written in lisp.
<pjb> This racism against uppercase is ridiculous!
<lotuseater> oh noez racism isn't good :/
tyson2 has quit [Remote host closed the connection]
cuz has quit [Ping timeout: 268 seconds]
brettgilio has quit [Quit: The Lounge - https://thelounge.chat]
brettgilio has joined #commonlisp
selwyn has quit [Read error: Connection reset by peer]
<CptJimKirk> @saturn the purpose of defapl is that I want CL to be the driver of APL programs, or a means to compose APL programs, so I would like to define LISP funcitons that are able to call into APL functions as needed, by feeding the "return value" of the "function body" to be passed as valid April input
<CptJimKirk> So conceptually, I'm passing input to a lisp function, but actually its calling the APL function of the same name
<CptJimKirk> But the issue is APL functions are case sensitive
<mfiano> So are lisp functions
<CptJimKirk> so how do defuns intern their symbols so that they are permitted to be case sensitive?
<mfiano> They already are
<mfiano> You just have some learning to do on how symbols are read by the Lisp reader.
<CptJimKirk> where do you suggest I turn for such knowledge
<mfiano> Common Lisp Recipes book has good information on symbols. Practical Common Lisp probably touches on it.
<CptJimKirk> hmm. I read that one a long time ago, but must be forgetting more than I imagine
<mfiano> Understanding the Lisp reader in detail is critical to effective programming. I suggest going back to it if you didn't retain it.
<CptJimKirk> I mean, I've spent so much time in the lisp liturgy that I've never actually built anything, but now that I have a project worth building I can't get it done without more bookiness?
<mfiano> I don't know how you learn.
<CptJimKirk> I'm not offended at the suggestion to turn to a great book for wisdom. I'm more offended at my inability to move past dwelling on reading books instead of building anything
<Alfr> CptJimKirk, does your defapl really define something (like a function etc.) in lisp, from your description it sounds to me that it simply should return something that hopefully is valid input for april. You could opt for mapping lispy-names-like-this to not that lispNamesLikeThis.
<CptJimKirk> I don't know many peopel who have spent so long with a language to have written so little
<CptJimKirk> @alfr if I understand what you're saying, I'm trying to infer the APL name from the name of the (defapl name ...
<CptJimKirk> so `(defapl myAplFn (args) (process (to-array (something-else input))))` or some such would pass the result of that body to a function from April called `myAplFn`
<mfiano> It is pointless to type myAplFn
<Alfr> CptJimKirk, yes.
<CptJimKirk> inside the macro, it expands somewhere `(defmacro defapl name .... (april-c "myApl"fn" results)... )`
<mfiano> Use |myAplFn|
<lotuseater> maybe better providing a readmacro for it
<CptJimKirk> that's awful
<lotuseater> to avoid the pipes
<mfiano> Then use a string
<CptJimKirk> I've thought about both of those
<mfiano> Or change the reader
<lotuseater> or that
<CptJimKirk> that's what I was trying to do
<CptJimKirk> but I don't know how to scope that
<mfiano> Well, one can't progress very far with being hung up on the fundamentals
<CptJimKirk> I thought something like this would work (let ((count 0)) (defun incrmentr () (setf count (1 + count))))`
<mfiano> If you have been learning Lisp for a long time, I suggest spending time on the important parts
<CptJimKirk> by wrapping the `defmacro` in redefining the reader case, but that def doens't work
<mfiano> Umm
<lotuseater> mfiano: well said :) or first learning how to swing the wand before using
<CptJimKirk> @mfiano I don't think reader macro definition is "fundamentals"
<mfiano> The reader itself. No macros involved
<CptJimKirk> I would say that's pretty "advanced usage"
<mfiano> Umm, ok
<CptJimKirk> tell me what other language allows you to manipulate the way its parsed at runtime?
<CptJimKirk> I would say that alone makes it not "fundamentals"
<Alfr> CptJimKirk, the function is 1+, you called the function 1.
<mfiano> I would argue if you don't like the power of Lisp, which requires knowledge to use the power effectively, go back to writing APL in APL
<lotuseater> CptJimKirk: but it's good to be aware that '(#\( #\) #\; #\" ...) are readmacros
<CptJimKirk> @alfr sorry, I'm not accustomed to developing in an irc chat
<CptJimKirk> @mfiano that is not a concluion that can be drawn from what I'm trying to do here
<CptJimKirk> I'm asking how
<lotuseater> Alfr: with |1| it could be indeed used as a function symbol ^^
<CptJimKirk> I'm asking for how I can find out
<CptJimKirk> becaues I would like to know, not because "I don't like ..."
<mfiano> I gave several solutions.
<CptJimKirk> you gave alternatives, but not solutions
<CptJimKirk> (defapl |caseSensitive| (args) body) is an alternative
<CptJimKirk> not a solution
<Alfr> lotuseater, just don't.
<mfiano> If you're going to argue semantics, I have no more desire to help. This is not #clschool after all.
<lotuseater> Alfr: of course not :P
<CptJimKirk> I don't know how I wound up in an argument
<CptJimKirk> I'm trying to do something specific
<CptJimKirk> and I want to know how
<CptJimKirk> changing the reader I don't understand
<CptJimKirk> I was trying to direct my line of questioning there before we wound up down this tangent
<CptJimKirk> I did change the reader, but it didn't work the way I expected for obvious reasons, the language is read outside of the context of the re defined readtable
<CptJimKirk> but also, I don't want the user to have to know to update the read table every time they want to use (defapl
<CptJimKirk> I'd like it to be as immediately useful as (defun or (defvar or (defparameter
<CptJimKirk> and I don't have to toggle a statemachine updating the readtable every time I want to use those
<mfiano> Reading happens before everything in the Lisp compiler. I don't know how you plan to accomplish that if you don't want to use a string name.
<CptJimKirk> so I'm not playing semantical games, I'm being specific, I want to be able to define in terms of a normal lisp binding form like `defun`, without having to use || or a string
CrashTestDummy2 has joined #commonlisp
<Alfr> lotuseater, and I guess the number 1 also won't denote a function.
<mfiano> Either use the reader, which forces a burden on users, or require them to use strings and do the work at macroexpansion time
<lotuseater> no the number alone not
<Alfr> lotuseater, that's what would've been read.
<CptJimKirk> is there a way to define a special form that isn't a macro?
<mfiano> You cannot define a special form
<mfiano> Macros are not special forms
<lotuseater> CptJimKirk: you could have it with brackets, [define camelCaseFunction ...] so that just the second symbol will be case preserved
<Alfr> CptJimKirk, there are only that many special operators, and you can't define more.
<CptJimKirk> lotuseater how does that work?
CrashTestDummy has quit [Ping timeout: 265 seconds]
<lotuseater> Alfr: but i can do (defun |1| (x) (1+ x)) and call it normally as a function
<CptJimKirk> can you explain how [define caseSensitive ...] works?
<CptJimKirk> I've never heard of that
<mfiano> By defining a reader macro dispatching on #\[.
<lotuseater> CptJimKirk: *you* define that :)
<Alfr> lotuseater, you'd still have to write |1|, \1 or some such when calling your |1|-function.
<lotuseater> or with { and } or whatever you like
<lotuseater> yes
<mfiano> Which requires the user to switch to your custom readtable, since that is a toplevel form
<mfiano> He expressed his disinterest with doing that
<CptJimKirk> yes I dont want MORE work than there is already
<Alfr> lotuseater, and |1| should return something constant imo.
<mfiano> Then use strings\
<mfiano> or pipes
<lotuseater> ah okay, it's late (or now again early) for me
<mfiano> No other way
<lotuseater> Alfr: your opinion?
<CptJimKirk> I just think this is the first time I've encounered "nope can't do that" in CL
<mfiano> By the time a macro sees its input, the Lisp reader has already read the input
<CptJimKirk> right
<mfiano> If you do not want to leverage the Lisp reader, you must use what is already available at read time
<CptJimKirk> that's what I didn't account for with the let block
<lotuseater> of course it's doable?
<CptJimKirk> no it isn't doable. The specific conditions I laid out have to this point I've been told that what I specified is not possible
<mfiano> You can, you just placed a lot of constraints that only open up 2 paths to a solution.
<CptJimKirk> right, I was working with strings earlier
<CptJimKirk> but it no longer read like a binding form
<CptJimKirk> it looked instead like a function
<lotuseater> so your specific conditions are well unspecific?
<CptJimKirk> function *invocation
<CptJimKirk> I don't know what that means?
<mfiano> Another option would be to require the user to define their def forms in a file that is not loaded, and manually call #'load in some function, installing a read table around it
<Alfr> lotuseater, maybe? (defun \1 () '(()))
<mfiano> Or something
<CptJimKirk> The user wants to be able to "call apl functions" in their lisp code, appearing like any other lisp function, but which ultimately binds to the April function by the same name, which should be definable ad-hoc without the need to manually update some global state machine for defining, either that or it would need to be defined within a block that
<CptJimKirk> shadows the *readtable* which means that not only can I not bind the lisp macro to the april funciton ad-hoc, but its scope specific, and would require a recompilation of the entire reader macro block every time I make any change
<CptJimKirk> That is well SPECIFIC
<lotuseater> ahja
<CptJimKirk> I can (defun my-fn (args) body) I want to (defapl myAplFn (args) body) just the same
<CptJimKirk> without the user needing to know a bunch of tricks for using it
<CptJimKirk> like, using - to mark the next character as upercase, while assuming lower case
<CptJimKirk> or (defapl "myAplFn" ...) because that doesn't look like binding
<CptJimKirk> I wouldn't assume looking at this expression that there is a lisp function now defined called "myAplFn"
<mfiano> As mentioned, you are out of luck with all those restrictions.
<CptJimKirk> and (defapl |caseSensitive| ...) is just a gotcha that you'll have to remember any time there is a apl fn with multiple case
<CptJimKirk> well its good to know that I don't have any other options at least
<CptJimKirk> I don't understand... Are you suggesting that any time a reader macro is used, that the user of the reader macro has to define all of their code from within the scope of that reader macro?
<mfiano> Yes, reader macros are global. There is named-readtables that helps with that a little bit.
<lotuseater> you use readmacros all the time
<mfiano> Or rather there is only 1 read table
<CptJimKirk> which ones?
<mfiano> ( is a reader macro
<lotuseater> (, ), ", ', ;, ... and the ones with dispatch
<Alfr> clhs 2.4
<Alfr> CptJimKirk, ^
<lotuseater> or when you use backquote, then in its context it activates , and ,@
<CptJimKirk> but those are global
<lotuseater> and?
<CptJimKirk> and if I set the readtable to :preserve global defined symbols will be undefined
<mfiano> The reader is a parser that operates on string data.
<lotuseater> hm no, but i know what you mean
<mfiano> There is no scopes
<CptJimKirk> ok, they'll be defined but I'm not going to go aroun (IF (CONS-P (CADADR...
<lotuseater> CONSP :)
<CptJimKirk> w/e
<CptJimKirk> I would find out right quick if I were in my repl :C
<mfiano> You mean (null atom)
<mfiano> :)
<CptJimKirk> i was jut thinking of things to type :C
<mfiano> Err
<mfiano> (null (atom x))
<CptJimKirk> why was there never any consideration for a (defreader which would pass the remaining expression to the body of the reader, which would then read the body?
<CptJimKirk> that seems like a glaring oversight/misstep?
<saturn2> if you want your system to be usable by lisp programmers the way they expect, without learning anything new or doing anything unusual, the only way is to explicitly map ordinary all-uppercase symbols to apl function names
<CptJimKirk> which would mean I need to define all my APL names in all upcase
<CptJimKirk> which is VERY retro ;)
<hayley> That makes no sense. I mean, if you have "the remaining expression", you already read it.
<CptJimKirk> @hayley (defreader (............)) the (...) could be a string completely unevaluated
<mfiano> Yeah there seems to be a big misunderstanding of the Lisp reader still.
<saturn2> i would suggest something like (defapl my-apl-fun "myAplFun" (args) body)
<CptJimKirk> that is not a valid APL function name
<CptJimKirk> oh
<CptJimKirk> hmm, that might be a thing to do
<saturn2> then you have a lisp name, and an apl name
<CptJimKirk> yeah
<CptJimKirk> just specify both
<beach> Good morning everyone!
<CptJimKirk> clumsy, but the most "makes sense" form so far
<lotuseater> Hi there beach :)
<CptJimKirk> hello
<mfiano> Look at how cffi, burgled-batteries, and other foreign interfaces
<mfiano> ...do it.
<Alfr> CptJimKirk, the problem with what you expect is, that you think that the call to (defreader .............) sees the dots, it doesn't.
<CptJimKirk> might do (defaple (lisp-fn apl-fn) (args) body)
<hayley> CptJimKirk: The reader always leaves things unevaluated. But it still has to do some "parsing" in order to find the matching ) eventually.
<CptJimKirk> s/defaple/defapl
<CptJimKirk> does it have to parse, or just match the count of open an closing parens until the stack is 0?
<CptJimKirk> regardless
* Alfr donates some #. to hayley.
<CptJimKirk> (defreader (....)) could be defined as just "reading a text string" until the matching closing paren, no parsing, then pass the string to the custom reader "macro/function" thing
<Alfr> clhs 2.2
<Alfr> CptJimKirk, ^
<CptJimKirk> i'm not arguing about how it IS, I'm asking why this wouldn't work in a special-case special-form type thing
<CptJimKirk> as in why is this kind of design not feasible to implement, since it is not
<beach> Because things are read before they are evaluated.
andrei-n has joined #commonlisp
<lotuseater> sounds a bit like going back to primitive C-ish macros that just set in text ...
taiju has joined #commonlisp
<CptJimKirk> but IF in this hypothetical form that doesn't actually exist, if it didn't EVALUATE, and only read the contents as a string?
<CptJimKirk> why would that be so inconceivable?
<beach> The reader would have to parse the name of the "special form" which is not what the reader does or is designed to do.
<CptJimKirk> oh
<beach> The reader turns characters into syntax trees.
<CptJimKirk> right, back to my first mistake of the evening
<Alfr> CptJimKirk, once you identify the special form symbol, the reader already has parsed and returned the list (you-new-and-shiny-special-form-symbol-name maybe some args).
<Alfr> Tough usually upcased.
<CptJimKirk> what about ##'#'*D->(readermacro ...) as some kind of prefix annotation to tell the reader "hey this thing is something else"?
<Alfr> Good morning, beach.
<CptJimKirk> that could trigger something in the readers statemachine, oh this is something else
<Alfr> CptJimKirk, you can then quite freely determine how you proceed reading; maybe #@, as #a is already used for denoting arrays.
<mfiano> ?
<Alfr> clhs 2.4.8
<mfiano> @ is unavailable to use by the user
<Alfr> mfiano, what? It's undefined, and I assumed he'd start modifying the standard readtable.
<mfiano> Just because it is undefined in ANSI doesn't mean a conforming implementation is not allowed to define it
<Alfr> mfiano, in the initial read table.
<CptJimKirk> I think what I'm learning is I need to stop trying to treat CL as having a pure subset
<CptJimKirk> Because that isn't a thing, setting global state is just a part of life in CL
<CptJimKirk> s/setting/mutating/
jealousmonk has quit [Read error: Connection reset by peer]
<CptJimKirk> this was helpful
<lotuseater> oh yes that's good
<beach> CptJimKirk: The other thing I recommend you do is avoid phrases such as "a glaring oversight/misstep" about how Common Lisp was designed.
lisp123 has joined #commonlisp
CptJimKirk has quit [Quit: Client closed]
CptKirk92 has joined #commonlisp
<CptKirk92> how else should I say that having a globally specified hook into the reader macro that doesn't mutate global state would be better than mutating global state?
CptKirk92 is now known as CptJimKirk
<CptJimKirk> not sure why I was disconnected... odd
<beach> Well, phrases like that seem to suggest that you know how Common Lisp was designed and that the people who designed it made a mistake. But in fact, the design is very consistent and the people who designed it were (are?) very smart and very knowledgeable.
<CptJimKirk> Clearly, I have tried and failed at implementing my own languages. To create such a universal grammar for a programming language required keen insight. I probably know more about the history of CL and APL than I do about writing quality applications with them... :/
<CptJimKirk> I just meant that this seems like an obvious thing to include in the spec is all
lisp123 has quit [Ping timeout: 265 seconds]
<CptJimKirk> but looking at other reader macro examples, it seems clear that mutating global state is the norm in CL, and I should just get acclimated to that.
<Alfr> CptJimKirk, why does it have to modify global state? (let ((*readtable* my-readtable)) (read some-input-stream)) can cover may things.
<CptJimKirk> only if all of your definitions using that reader macro are defined within that let block
<CptJimKirk> but that json reader macro example showed an enable/disable function which overwrote the reader, copying the original to some stack of read-table history
<Bike> as already mentioned, named-readtables lets you do things in a more declarative way
<CptJimKirk> but then he corrected himself about named-readtables and said there is only 1 read-table
<Bike> well, there's only one current readtable, yeah. i don't know what having more than one simultaneously would mean. there's only one syntax.
<Alfr> clhs copy-readtable
<Alfr> CptJimKirk, ^
<Bike> but you can keep readtables around as objects and stuff.
<Alfr> CptJimKirk, you can have as may as your memory holds.
<CptJimKirk> My current position is basically that a custom reader macro for this particular case is way nuclear of an option for just trying to maintain case
<Bike> *readtable* kind of is the globally specified hook into the reader. there are lots of ways to mutate readtables, though.
<Alfr> CptJimKirk, but in a program (let's not consider special variables and threads right now) you can only have one effective readtable at any moment.
<CptJimKirk> I'll probbaly roll with saturns suggestion from earlier about (defapl (lisp-fn "AplFn") (args) (body))
Skyfire has quit [Quit: brb]
Skyfire has joined #commonlisp
semz has quit [Ping timeout: 252 seconds]
lotuseater has quit [Ping timeout: 260 seconds]
semz has joined #commonlisp
Bike has quit [Quit: Lost terminal]
pranavats has joined #commonlisp
dre has joined #commonlisp
shka has joined #commonlisp
akoana has left #commonlisp [#commonlisp]
andrei-n has quit [Quit: Leaving]
pieguy128 has quit [Quit: ZNC 1.8.2 - https://znc.in]
pieguy128 has joined #commonlisp
asarch has joined #commonlisp
srhm has quit [Read error: Connection reset by peer]
srhm has joined #commonlisp
shka has quit [Quit: Konversation terminated!]
lisp123 has joined #commonlisp
doyougnu has quit [Ping timeout: 252 seconds]
scymtym has quit [Ping timeout: 268 seconds]
Nilby has joined #commonlisp
Nilby has quit [Remote host closed the connection]
Nilby has joined #commonlisp
lisp123 has quit [Remote host closed the connection]
lisp123 has joined #commonlisp
<lisp123> Does anybody know which implementations are unable to successfully extract a function expression from a function symbol via function-lambda-expression?
<beach> I am willing to bet that the commercial implementations will not let you get the source code of their compiler that way.
<beach> Also, for the generic functions in any implementation, I don't think there is anything reasonable to return.
<lisp123> Thanks on both counts, that's useful to know. I hope the commercial implementations will allow it for user functions..
<lisp123> I think its a very useful tool, if I want to create a macro that takes a function as an input and does a transformation, it makes it much easier to just use that
<lisp123> vs. asking the user to type in the expression
selwyn has joined #commonlisp
jemoka has quit [Remote host closed the connection]
jemoka has joined #commonlisp
jemoka has quit [Remote host closed the connection]
jemoka has joined #commonlisp
<moon-child> 'for the generic functions...' (typecase...)? ;)
jemoka has quit [Remote host closed the connection]
<beach> Interesting idea.
asarch has quit [Quit: Leaving]
Qwnavery has joined #commonlisp
jemoka has joined #commonlisp
jemoka has quit [Remote host closed the connection]
jemoka has joined #commonlisp
lisp123 has quit [Remote host closed the connection]
lisp123 has joined #commonlisp
jemoka has quit [Remote host closed the connection]
jemoka has joined #commonlisp
lisp123 has quit [Remote host closed the connection]
CptKirk has quit [Ping timeout: 268 seconds]
lisp123 has joined #commonlisp
CptJimKirk has quit [Ping timeout: 256 seconds]
<lisp123> moon-child: How would that work?
<beach> lisp123: The TYPECASE would emulate the discriminating function, and each case would be the method function of one method.
<lisp123> And the method function would be a standard function (and not a DEFMETHOD one) yes?
<beach> Method functions are ordinary functions.
<beach> mop method-function
<lisp123> Oh nice! Thanks - learnt something new!
heisig has joined #commonlisp
pillton has quit [Ping timeout: 260 seconds]
<beach> lisp123: The only thing they really had to add to pre-ANSI Common Lisp to get CLOS was the STANDARD-OBJECT and the FUNCALLABLE-STANDARD-OBJECT.
<lisp123> I see
<beach> lisp123: Classes are just STANDARD-OBJECTs, and generic functions are just FUNCALLABLE-STANDARD-OBJECTs.
gaqwas has joined #commonlisp
<lisp123> I see - its a bit over my head but parts of it make sense
<beach> Sure.
igemnace has joined #commonlisp
pve has joined #commonlisp
rain3 has joined #commonlisp
rgherdt has joined #commonlisp
hendursa1 has joined #commonlisp
hendursaga has quit [Ping timeout: 276 seconds]
heisig has quit [Quit: Leaving]
selwyn has quit [Read error: Connection reset by peer]
selwyn has joined #commonlisp
selwyn has quit [Read error: Connection reset by peer]
cage has joined #commonlisp
kakuhen has quit [Quit: Leaving...]
<pve> Good morning! I was listening to the Lex Fridman podcast where he discusses "Cyc" with Douglas Lenat, and there's a part that may be of interest to lispers.
<pve> They only talk about "Lisp", but I wonder if it's really Common Lisp under the hood?
<moon-child> I believe cyc was implemented in common lisp but itself used only an s-expression syntax
<pve> moon-child: yes, they also mention a "subset of lisp" called "subl", maybe that's it?
amb007 has quit [Remote host closed the connection]
<moon-child> hmm, opencyc seems to be mostly java!
<moon-child> so I was wrong about that
<pve> moon-child: Douglas says they translate "subl" into java or c
<moon-child> see also logicmoo, which is an oss continuation of cyc. It includes this gem https://github.com/logicmoo/wam_common_lisp, which '[Allows] Lisp programs to stop implementing an ad-hoc, informally-specified, bug-ridden, slow implementation of less than half of ISO-Prolog' :D
<pve> haha
<moon-child> pve: just from scanning filenames, it seems the actual inference engine is in java. See https://github.com/asanchez75/opencyc/blob/master/KB%2Binference_engine/opencyc-0.7.0b.zip
selwyn has joined #commonlisp
amb007 has joined #commonlisp
<moon-child> oh, huh, the inference engine is apparently translated to java too
<White_Flame> there's also this: https://github.com/white-flame/clyc
<White_Flame> yeah, the engine is written in subl, which is a cut-down lisp intended to be translated to C/Java/etc for execution
<White_Flame> I'm going through as much as I can get my hands on in terms of figuring out how it works. Especially interesting to me are how its pluggable inference modules work
<pve> White_Flame: I did stumble upon clyc when searching around :)
<White_Flame> I'm rewriting it, starting from data imports. The dependency ordered file porting approach was way too unwieldy
<White_Flame> at least starting from data import, I can get a better sense of what data is actually there, instead of just a bunch of opaquely named datastructures interconnecting strangely
<pve> White_Flame: I assume they did not release the subl "translator"?
<White_Flame> hmm, I haven't looked for that. Subl itself is documented, so it wouldn't surprise me if that's actually public
amb007 has quit [Read error: Connection reset by peer]
<pve> oh
<White_Flame> well, by "public" I mean "published its java conversion in larkc" ;)
<pve> White_Flame: he briefly explains in the podcast how the inference modules work, it sounds a lot like a blackboard system
<White_Flame> ok, I'll give it a listen
<pve> let me see if I can find the relevant part
<White_Flame> I think lenat himself has gotten away from the actual technical details and mostly gives marketing descriptions nowadays
<White_Flame> but with snippets from people who actually work at cycorp, it really sounds like it's a ton of manual labor to hardcode various modules to keep it from spinning to death & focus on specific problems, not that it magically finds its own way
<White_Flame> ah, this is an interview with lenat
<pjb> Yes, it's a big mess.
<pjb> The only thing it has for it, is that it brings money to work on an AI project…
lisp123 has quit [Remote host closed the connection]
<pjb> But that means a lot of overhead.
amb007 has joined #commonlisp
lisp123 has joined #commonlisp
lisp123 has quit [Ping timeout: 265 seconds]
* White_Flame is listening to the whole thing at 2x
<White_Flame> speed
leo_song has quit [Quit: ZNC 1.7.2+deb3 - https://znc.in]
leo_song has joined #commonlisp
<pve> He does paint a pretty picture. It's sad if it's a big mess in reality.
<White_Flame> at the very least, the code has excessive legacy & massive technical debt built up, which makes it hard to work on
<White_Flame> the design of subl was basically oriented around memory & speed efficiency for much older execution environments
aleamb has joined #commonlisp
<White_Flame> from a knowledge engineering perspective, I hope they've kept everything cleaner, but much of that isn't public
<White_Flame> there's been various releases of opencyc, and if they're all unioned together, might cover most of their actual core knowledge
<White_Flame> (those KBs are apache licensed, but in a fasl-like binary form)
<White_Flame> but the inference models are subl, not cycl (the knowledge language)
<pve> oh, I was wondering what cycl was
lisp123 has joined #commonlisp
lotuseater has joined #commonlisp
scymtym has joined #commonlisp
<White_Flame> that's a pretty good interview, but yeah the technical details aren't beyond what's described in publicly findable documentation. A good intro, though
tyson2 has joined #commonlisp
xsperry has joined #commonlisp
amb007 has quit [Ping timeout: 260 seconds]
amb007 has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
contrapunctus has left #commonlisp [#commonlisp]
contrapunctus has joined #commonlisp
random-nick 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
frgo has quit [Remote host closed the connection]
frgo has joined #commonlisp
pranavats has left #commonlisp [Disconnected: Replaced by new connection]
pranavats has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
amb007 has quit [Ping timeout: 265 seconds]
amb007 has joined #commonlisp
amb007 has quit [Ping timeout: 268 seconds]
amb007 has joined #commonlisp
Everything has joined #commonlisp
X-Scale` has joined #commonlisp
X-Scale has quit [Ping timeout: 252 seconds]
X-Scale` is now known as X-Scale
sm2n_ has joined #commonlisp
sm2n has quit [Ping timeout: 268 seconds]
rain3 has quit [Ping timeout: 265 seconds]
dre has quit [Ping timeout: 268 seconds]
Qwnavery has quit [Quit: WeeChat 3.2.1]
CrashTestDummy3 has joined #commonlisp
CrashTestDummy2 has quit [Ping timeout: 268 seconds]
lisp123 has quit [Remote host closed the connection]
lisp123 has joined #commonlisp
lisp123 has quit [Ping timeout: 252 seconds]
selwyn has quit [Read error: Connection reset by peer]
srhm has quit [Read error: Connection reset by peer]
srhm has joined #commonlisp
lisp123 has joined #commonlisp
rain3 has joined #commonlisp
cosimone has joined #commonlisp
lisp123 has quit [Remote host closed the connection]
lisp123 has joined #commonlisp
Lycurgus has joined #commonlisp
lisp123 has quit [Ping timeout: 252 seconds]
cosimone` has joined #commonlisp
cosimone has quit [Ping timeout: 268 seconds]
hendursa1 has quit [Quit: hendursa1]
yitzi has joined #commonlisp
X-Scale` has joined #commonlisp
X-Scale has quit [Ping timeout: 260 seconds]
X-Scale` is now known as X-Scale
hendursaga has joined #commonlisp
lisp123 has joined #commonlisp
xsperry has quit [Remote host closed the connection]
amb007 has quit [Ping timeout: 265 seconds]
Inline has quit [Quit: Leaving]
perrierjouet has quit [Quit: WeeChat 3.2]
lisp123 has quit [Ping timeout: 252 seconds]
perrierjouet has joined #commonlisp
lotuseater has quit [Ping timeout: 268 seconds]
amb007 has joined #commonlisp
Inline has joined #commonlisp
Inline has quit [Client Quit]
Inline has joined #commonlisp
perrierjouet has quit [Quit: WeeChat 3.2.1]
xsperry has joined #commonlisp
lisp123 has joined #commonlisp
ln43 has joined #commonlisp
waleee has joined #commonlisp
lisp123 has quit [Remote host closed the connection]
lisp123 has joined #commonlisp
ln43 has quit [Quit: Connection closed]
Lycurgus has quit [Quit: Exeunt]
perrierjouet has joined #commonlisp
igemnace has quit [Remote host closed the connection]
amb007 has quit [Ping timeout: 252 seconds]
amb007 has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
fitzsim has quit [Remote host closed the connection]
hendursaga has quit [Ping timeout: 276 seconds]
hendursaga has joined #commonlisp
amb007 has joined #commonlisp
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
jemoka has quit [Remote host closed the connection]
jemoka has joined #commonlisp
amb007 has quit [Ping timeout: 240 seconds]
contrapunctus has left #commonlisp [#commonlisp]
amb007 has joined #commonlisp
contrapunctus has joined #commonlisp
waleee has quit [Ping timeout: 252 seconds]
waleee has joined #commonlisp
contrapunctus has left #commonlisp [#commonlisp]
contrapunctus has joined #commonlisp
perrierjouet has quit [Quit: WeeChat 3.2.1]
rgherdt has quit [Ping timeout: 252 seconds]
selwyn has joined #commonlisp
contrapunctus has left #commonlisp [#commonlisp]
selwyn has quit [Remote host closed the connection]
selwyn has joined #commonlisp
lisp123_ has joined #commonlisp
lisp123__ has joined #commonlisp
lisp123 has quit [Ping timeout: 252 seconds]
yitzi has quit [Quit: Leaving]
lisp123_ has quit [Ping timeout: 252 seconds]
nature has joined #commonlisp
rgherdt has joined #commonlisp
rotateq has joined #commonlisp
amb007 has quit [Ping timeout: 268 seconds]
amb007 has joined #commonlisp
contrapunctus has joined #commonlisp
nature has quit [Ping timeout: 252 seconds]
contrapunctus has left #commonlisp [#commonlisp]
yitzi has joined #commonlisp
selwyn_ has joined #commonlisp
selwyn has quit [Ping timeout: 252 seconds]
<nick3000> Does anyone know if there is a simple way to create a 'bivalent' (I think I'm using that word right) in-memory stream with flexi streams or some other library? I was thinking some kind of class that just writes to one stream and reads from another. I want that because I am unit-testing some TCP-socket code that reads and writes to a socket. I was thinking if that was super hard I would just pass my server code two different streams,
<nick3000> for writing and another for reading, rather than build my own stream.
molson_ has joined #commonlisp
molson__ has quit [Ping timeout: 268 seconds]
<rotateq> you mean bidirectional?
<nick3000> Yeah
dstein64 has left #commonlisp [#commonlisp]
<nick3000> THe flexistream manual does use the word 'bivalent' but when I click the link to find a definition it does not point to anything with the word 'bivalent'.
<Nilby> bivalent means it can write both characters and bytes
<rotateq> okay I don't know it, you may have a link?
<rotateq> ah good to know
<rotateq> clhs bidirectional
<specbot> Couldn't find anything for bidirectional.
<rotateq> args :)
<Nilby> a bidirectional stream just can be both read from and written to
<nick3000> Okay so that is what I was looking for, if there was a library that allowed me to take an input and output stream and wrap them into a single bidirectional stream.
<nick3000> Since in-memory flexi-streams are unidirectional.
<nick3000> as far as I can tell...
<Nilby> nick3000: maybe you could use a two-way-stream
<nick3000> Ah yes exactly what I'm looking for
<nick3000> Thanks
<rotateq> i also like make-broadcast-stream
<rotateq> oh this is a cool graphic
contrapunctus has joined #commonlisp
<lisp123__> Nilby: cool chart, did you create it with a program?
<Nilby> yes
<Nilby> but unfortunately I haven't published my text drawing program because it's not an emacs yet
<rotateq> for what is a synonym stream? i see it now in the CLHS symbol list with make-*
<Nilby> synonym stream is like an alias to another stream, e.g. so you can have a stream that is actually writes to whatever *standard-output* is set to
<pjb> nick3000: for a bidirectional stream, you need two streams, (four ends) and connect their ends with make-two-way-stream.
<pjb> nick3000: you may also want to use pipes.
<lisp123__> Nilby: Nicely done, looking forward to seeing it one day
<pjb> cf. com.informatimago.clext.pipe
<nick3000> Thanks Nilby and pjb. make-two-way-stream was exactly what I was looking for.
<Nilby> nick3000: glad to help.
<Nilby> It always seemed strange that the simple pipe stream not included in CL.
<Nilby> I guess maybe since they didn't actually get gray streams in
<loke[m]> Nilby: Because pipe streams doesn't really work in a single threaded API
<loke[m]> Java also don't have them.
<Nilby> loke[m]: Ah. That makes sense.
<Nilby> excluding the java part ;]
azimut has joined #commonlisp
perrierjouet has joined #commonlisp
cognemo has quit [Ping timeout: 250 seconds]
azimut_ has quit [Ping timeout: 276 seconds]
<pjb> pipes are an IPC synchronization mechanism.
<pjb> They're based on a semaphore (buffer size).
contrapunctus has left #commonlisp [#commonlisp]
contrapunctus has joined #commonlisp
sander has quit [Ping timeout: 265 seconds]
VincentVega has joined #commonlisp
CptKirk has joined #commonlisp
CptKirk has quit [Client Quit]
Lycurgus has joined #commonlisp
igemnace has joined #commonlisp
<jcowan> Also, CL was meant to work on non-Posix operating systems that didn't have pipes.
<jcowan> (except VM/CMS)
<jcowan> likewise Java
rain3 has quit [Ping timeout: 268 seconds]
CptKirk has joined #commonlisp
<CptKirk> I'm searching for a loop form that cycles over a list
<CptKirk> I have a list of "0 1" and I want to repeatedly cycle over that list say, 10 times, collecting items from the list. say 0 1 0 1 0 1 0 1 0 1
sander has joined #commonlisp
<CptKirk> I can of course write this in raw lisp, but I'm looking for a loop macro that does this if there is one
<lisp123__> (dotimes 10 (loop for item in list append item))
<lisp123__> Does that work?
amb007 has quit [Ping timeout: 252 seconds]
<yitzi> Your dotimes is malformed.
<lisp123__> yitzi: Yeah noticed that
<lisp123__> Fixing it now
<Nilby> (loop for i in' #1=(0 1 . #1#) do (print i))
contrapunctus has left #commonlisp [#commonlisp]
<CptKirk> (setf ns (loop for i from 1 to 100 for j in '(1 2) collecting j))
<CptKirk> I would have thought this would do it
contrapunctus has joined #commonlisp
<CptKirk> but I guess it only goes for the min length of either list
<lisp123__> CPtKirk - look into (look for item in list append ...)
<lisp123__> some combination of that will get you what you want
<Nilby> er, um, (loop for i in' #1=(0 1 . #1#) repeat 10 collect i)
<CptKirk> I don' kow what that #1= #1# stuff is
<lisp123__> Nicely done
<Nilby> reader macros to make a circular list
<CptKirk> ah, clever
<Nilby> splice itself in itself
<Nilby> you can do it without macros too
<lisp123__> (loop for x from 1 to 10 append (loop for item in '(0 1) append (list item)))
<lisp123__> But append is highly inefficient, just wanted to show that its a useful keyword in the loop macro
amb007 has joined #commonlisp
<yitzi> If you are not trying to do processing along the way (apply #'append (make-list 10 :initial-element '(0 1)))
<rotateq> CptKirk: in general the #n= is for labeling a form and with #n# you can recall it so that the reader sets the form in at that place too
<CptKirk> wow
<Alfr> CptKirk, for a non-circular list L which you are allowed to modify: (setf (cdr (last L)) L)
<rotateq> sometimes very useful but shouldn't be used in real source files
<CptKirk> how does the interpreter handle the circular list?
<CptKirk> it only reads when reading the value of that slot? or....
<Nilby> It's just a copy and paste. The reader just copies #1 where it sees #1#. The cons cell is already created before it's contents are put in.
<Alfr> CptKirk, it's not clear what you're asking. But as CALL-ARGUMENTS-LIMIT is an integer, it's finite, thus a circular list can't be a function call form.
newlispurr has joined #commonlisp
<CptKirk> @nilby but when does it do that, clearly it can't do that infinitely?
<CptKirk> @alfr I'm asking at what time does it expand the #1# reference because clearly it can't do that infinitely
<rotateq> you can view it as a kind of lazy list i would say (when handled correctly)
<CptKirk> how would you handle it incorrectly so I know what to avoid?
<rotateq> try out :)
<rotateq> maybe first (setq *print-circle* t)
<Alfr> CptKirk, it doesn't. A proper list is either nil or a cons whose cdr is a proper list.
<Nilby> It doesn't expand it in this case. It just creates it and the loop goes through it.
<Alfr> CptKirk, you get a circular list if you modify a cdr of a cons in a list to refer to some preceding cons of that list.
cage has quit [Quit: rcirc on GNU Emacs 27.1]
<Nilby> Here's without the reader trick:(let* ((l (list 0 1))) (setf (cdr (last l)) l) (loop for i in l repeat 10 collect i))
dre has joined #commonlisp
lisp123__ has quit [Remote host closed the connection]
lisp123 has joined #commonlisp
<newlispurr> How do I put imports in a file in Common Lisp? (I'm using Portacle) If I put (ql:quickload :local-time) on top of my .lisp file, and run C-c C-k (compile and load) it doesn't work, but if run (ql:quickload :local-time) in the SLIME REPL and then C-c C-k again it works.
igemnace has quit [Remote host closed the connection]
<newlispurr> What should I put in my .lisp file so I don't have to run (ql:quickload :local-time) in the REPL every time I restart Emacs?
lisp123 has quit [Ping timeout: 252 seconds]
<rotateq> you should put it in .sbclrc
akoana has joined #commonlisp
<Alfr> clhs eval-when
<Alfr> newlispurr, ^ and you usually want all three.
amb007 has quit [Read error: Connection reset by peer]
amb007 has joined #commonlisp
igemnace has joined #commonlisp
<newlispurr> rotateq, Alfr: ah I see, thanks, I'll read about it
newlispurr has quit [Quit: Client closed]
amb007 has quit [Ping timeout: 252 seconds]
amb007 has joined #commonlisp
Inline has quit [Quit: Leaving]
Inline has joined #commonlisp
lerax has joined #commonlisp
lisp123 has joined #commonlisp
Lycurgus has quit [Quit: Exeunt]
lisp123 has quit [Ping timeout: 265 seconds]
Everything has quit [Quit: leaving]
lerax has quit [Ping timeout: 265 seconds]
sander has quit [Remote host closed the connection]
kakuhen has joined #commonlisp
<pjb> Alfr: also, you should not put quicklisp stuff in lisp source files, but in asd files!
brettgilio has quit [Ping timeout: 252 seconds]
<pjb> jcowan: why do you think I implemented pipes with gray streams?
<jcowan> I don't know gray streams, so I cannot tell.
<Alfr> pjb, sure when I make one. Some of my stuff are just single files in PATH, that's what I assumed he wanted such behavior.
lerax has joined #commonlisp
<pjb> CptKirk: you cannot have circular structures in the source code, but you can have them in literal objects (quoted or self-evaluating).
<pjb> Alfr: so you explained how to use eval-when to put quicklisp in source file. Which is what he shouldn't be doing.
<CptKirk> :C confused
<pjb> CptKirk: the source code is processed by the compiler. if you use structuring sharing, including circular structures, then the compiler may not terminate, or have other bugs because of the sharing. But this doesn't matter for data, which is data, and is not processed by the compiler.
<pjb> CptKirk: the only processing of literal data the compiler performs, is possibly identifying common substructures in literals, and share them in the object file.
<pjb> CptKirk: ie. explicitely dealing with structure sharing including circular structures.
Lord_of_Life_ has joined #commonlisp
<Alfr> pjb, I never said it's best practice. And I usually use it with load-system only -- not ql.
<pjb> CptKirk: note: I use the term structure in a general way here, because #=/## can be used across cons cells, vectors, structure objects, and other read forms.
<pjb> Alfr: then you should have explained that to newlispurr…
Lord_of_Life has quit [Ping timeout: 240 seconds]
<pjb> Alfr: the penalty is that you might eventually have to maintain the bad code he writes…
<Alfr> I'll fix that after I get my time machine working, pjb.
Lord_of_Life_ is now known as Lord_of_Life
<pjb> Alfr: Great! :-)
<pjb> We should be prepared and have a backlog of issues for when it'll be possible.
terrorjack has quit [Remote host closed the connection]
terrorjack has joined #commonlisp
<Nilby> Too bad we would already know if time machines worked.
cosimone` has quit [Ping timeout: 260 seconds]
<rotateq> Alfr: what kind of time machine?
selwyn_ has quit [Read error: Connection reset by peer]
Nilby has quit [Ping timeout: 265 seconds]
White_Flame has quit [Remote host closed the connection]
White_Flame has joined #commonlisp
nature has joined #commonlisp
Oladon has joined #commonlisp
tfeb has joined #commonlisp
brettgilio has joined #commonlisp
nature has quit [Ping timeout: 265 seconds]
tfeb has quit [Quit: died]
nature has joined #commonlisp
specbot has quit [Remote host closed the connection]
minion has quit [Read error: Connection reset by peer]
minion has joined #commonlisp
specbot has joined #commonlisp
frgo has quit [Remote host closed the connection]
frgo has joined #commonlisp
<hendursaga> How should I go about typing a function that returns the output of an already-typed function? Just "function" and the rest is inferred or what?
srhm has quit [Read error: Connection reset by peer]
srhm has joined #commonlisp
<rotateq> do you mean giving the same construct a second symbol?
<rotateq> then an example could be when you want to abbreviate EXPT with ^, (setf (symbol-function '^) #'expt) and that probably wrapping in an eval-when. or with FDEFINITION instead of SYMBOL-FUNCTION, maybe to that point someone can say more detailed difference
<hendursaga> Like, the first function calls the second one in a specialized way and returns the result, thus the return type is the same for both.
<rotateq> noticeable is when you then do (fmakunbound 'expt) or just shadowing it in your package, the ^ is still usable
<rotateq> oh hm hm
<hendursaga> I'll just assume it infers it. Otherwise CL's typing system would seem really weak.
<rotateq> even if not, the type system is good and quite flexible
<rotateq> but how the inference goes is more left to the implementation you use
<rotateq> ah okay I think now I understand better for what your question goes
VincentVega has quit [Ping timeout: 265 seconds]
<hendursaga> In other words, the input types differ, but the output types should be the same.
<hendursaga> Like, say, a function that returned the area of a rectangle and one that returned the area for a square.
<rotateq> and you can use THE ;) or declare the type of your result in advance
<hendursaga> Could you "reference" the rectangle's type explicitly?
<rotateq> sure, when you provide classes and methods for your calculations
<rotateq> not really different from, say, the INTEGER, but this is a built-in class and normally the user defined ones are standard-classes
<rotateq> *the INTEGER class
<hendursaga> So how would I type square so that the output types part is the same as rectangle?
<rotateq> please specify your question more
<hendursaga> Never mind, I see "describe" shows the derived type, it works as is
<rotateq> with DECLAIM you can also specify the signature for your functions and methods
cuz has joined #commonlisp
gaqwas has quit [Ping timeout: 252 seconds]
<cuz> Would anyone mind helping me understand how (defun foo ()) is different from (defparamter foo (lambda ()))
<rotateq> are you coming from scheme? ^^
<rotateq> and yes, but i must think about it first
<cuz> no, one sec let me explain the context
<Alfr> hendursaga, consider: (defun f () 'foo) (defun g () (f)) I know of no implementation which derives that g will return a symbol.
<pjb> The interpretation of a type declaration is as follows: >
<pjb> 1. During the execution of any reference to the declared variable within the scope of the declaration, the consequences are undefined if the value of the declared variable is not of the declared type.
<pjb> 3. At the moment the scope of the declaration is entered, the consequences are undefined if the value of the declared variable is not of the declared type.
<pjb> 2. During the execution of any setq of the declared variable within the scope of the declaration, the consequences are undefined if the newly assigned value of the declared variable is not of the declared type.
<pjb> Therefore you really do not want to use type declarations since the only thing they do, is make your code more undefined!
<Alfr> hendursaga, most likely because you could later (defun f () 42); so that'd would then have to be fixed up.
<rotateq> cuz: a first thing that comes to my mind is, with DEFUN you also define a block you can explicitely return from
<cuz> I'm making a package and I want to split it into different files. I have this foo thing that I want to reference in a seperate file than the one it is defined. When I try to reference it while using defun I get an undefined variable warning from slime...
<pjb> The specifications of FTYPE is less precise, but I think we can safely infer the same kind of undefinedness will occur if you declare ftype of your functios.
<rotateq> and as a parameter you have to use funcall
<cuz> Hmmm I am using funcall... maybe thats whats bringing up the warning
<pjb> hendursaga: furthermore, what is the type of the function f of Alfr? It returns 42. different implementations say 42 is of type: (INTEGER 0 2147483647) (INTEGER 0 1152921504606846975) (INTEGER 0 1099511627775) (INTEGER 42 42) (INTEGER 0 4611686018427387903)
<pjb> hendursaga: If you have an implementatation for which it's (INTEGER 42 42) and you want to say that g is of same type, then g can only return 42 !!!
<pjb> But any other type is also wrong, why couldn't g return -1?
<rotateq> cuz: okay but you can in the second file put atop (in-package :my-pkg) and specify in your .asd that the second depends on the first where the function foo is initially defined. or do i miss something?
<pjb> hendursaga: so the answer to your original question is: yes.
<pjb> Anything else would be silly.
<rotateq> pjb: 42 is all you need :P
<Alfr> pjb, doesn't matter for that example definitely not symbol, as f initially gave back foo.
<Alfr> s/foo/'foo/
<pjb> (type-of 't) #| --> boolean |# :-P
<cuz> rotateq: yeah thats exactly what i'm doing but I get a warning if I use defun and no warning with defparameter. It's very odd imo, and I was begining to think there might be a different table for functions and parameters?
<moon-child> cuz: yes, that is exactly right, common lisp has multiple namespaces
<pjb> Type inference is not specified by the language. It's a technique a compiler can use, just like data flow or any other technique. I'm not sure the programmer has to make anything of it, apart from the fact that the human programmers make reason about the program in a similar way. Ie. we can infer that g returns foo (assuming the original f definition), but the human programmer must also assume that g may return anything else, because
<pjb> it can be redefined at run-time, or f can be redefined at run-time, or there may have been some non-standard reader macro on #\' or on #\f that makes 'foo read as something entirely different.
<moon-child> rather than (defun f ...), you might also say (setf (symbol-function 'f) (lambda ...))
<pjb> This is why there are function such as type-of and print !!!
<pjb> hendursaga: so stop thinking about types, you're programming in lisp!
<cuz> Ahh I didn't reference it with a #' ... rookie mistake
<pjb> It would be better to think in terms of classes. (but the details of class hierarchies are also implementation dependent).
<rotateq> or your impl compiler tells you "get of my lawn!"
<rotateq> cuz: oh "rookie", i like that word :)
<pjb> (class-name (class-of 42)) returns fixnum in 4 implementations, and integer in 1. fixnum is NOT a class defined in the CL standard!
<rotateq> today I learned another funny word "whippersnapper"
Oddity has quit [Ping timeout: 252 seconds]
<pjb> (but it's not against the standard to have a fixnum class as subclass of integer, so those implementation remain conforming).
<rotateq> pjb: yeah or the length in bits of a fixnum. on my machine for example: SBCL -> 62, CCL -> 60
* Alfr thinks that pjb should mention the merit of occasionally using check-type.
<pjb> your program could become non-conforming if you depended on fixnum as a class.
<pjb> hendursaga: hence again, even if classes are better than types, you should probably forget about them!
<pjb> Alfr: indeed, never use declare, use check-type if you really feel like it.
<pjb> Also, always use check-type in API or UI functions.
<rotateq> i got the difference of both like so in my head: DECLARE if it shall stay that type till the end, and CHECK-TYPE to check if it's at that point the type which can also vary later on
<pjb> rotateq: no. declare type as listed above, only gives you undefined behavior.
<pjb> it's totally useless.
<rotateq> right after i wrote it i had other thoughts again
<rotateq> many impl-dep stuff going with (declare (type ...))
<pjb> Exactly.
<rotateq> after all, for prototyping things such too narrow thoughts just stand in productivity's way
<rotateq> it's not the "oh now we are going to a for loop, so specify the 'int i;' before" :P
Oddity has joined #commonlisp
<cuz> Is there a way to save the state of a slime repl to come back to later?
pve has quit [Quit: leaving]