freenode/#lisp - IRC Chatlog
Search
21:42:11
jcowan
I don't think, given the desire to find the definition of function foo in a large codebase, would go searching for "(setf (fdefinition 'foo".
21:42:57
aeth
No, but I don't assume that functions are defined by defun, I assume they're defined by defun or define-*
21:43:15
jcowan
ACTION grumbles at the irregular definition of -, which means one thing for one argument and something totally different for 2+ arguments
21:43:17
aeth
Maybe I'm the only one who likes to write macros that write defuns rather than writing defuns directly for a lot of things (e.g. shaders)
21:43:38
aeth
If you have a pattern that creates a function, it would be reasonable to turn it into a macro called define-*
21:43:55
phoe
jcowan: I wouldn't search the codebase, I'd do M-. in slime and let it find the source for me
21:46:18
aeth
If I see a define-* in CL I assume it ultimately creates at least one of (1) a function, (2) a macro, (3) a standard-object, (4) a structure-object, or (5) a type. Unless it does something fancier like sets a value in a global hash table or something... but that probably should be replaced with a function that returns one value IMO.
21:51:08
aeth
(defmacro define-function-from-lambda (name lambda) `(progn (setf (fdefinition ',name) ,lambda) ',name)) (42+ 1) => 43
21:57:34
no-defun-allowed
it takes a string (might make it a downcased symbol later) and two lambdas and sets it in a hash-table
22:00:01
aeth
What I do instead of relying on an implicit global hash table is that I have an explicit function that takes in a list of symbols and does something with that. So e.g. define-shader defines a function that returns a shader object and define-shader-data contains a lists all of the shader objects. So defining a shader is a pure function with no side effects, but you have to define which shader-returning functions to actually use
22:01:16
aeth
Like this: https://gitlab.com/zombie-raptor/zombie-raptor/blob/8a028d9f2ecbdf1a4abe1912677e143ea9219aff/examples/shaders.lisp#L126-141
22:01:25
no-defun-allowed
they're only used internally and can only be named and found with #'find-codec so purity isn't a big problem for me
22:02:01
no-defun-allowed
so when my parser hits an atom `base64:AAAA` it funcalls (find-codec "base64" :decode) with "AAAA"
22:04:54
aeth
no-defun-allowed: You could probably replace that with a with-codec macro that binds the function to a variable so it's not looked up every time.
22:18:42
aeth
oni-on-ion: I can't tell when the CCL log bot isn't here, I just know that it usually cuts off around that point
22:19:42
oni-on-ion
ahh =) yeah. wasnt sure if your client may have truncated. this client here (weechat) automatically splits up a certain amount into seperate messages
22:20:39
aeth
It depends on the server and the size of the total IRC message (which includes some metadata like your nick) afaik. I get several more characters to work with than you.
2:54:58
ealfonso`
I want to mock a function like drakma:http-request within a unit test. Can I use flet? It seems that the scope of my flet binding is lexical, can I make it dynamic?
2:58:58
ealfonso`
does this gist mean I would have to implement it myself? https://gist.github.com/jasom/04606c9e418aee6f969c8b1fdf69ba68
3:04:12
oni-on-ion
ah ty! i was scrolling up feeling certain i seen something else in use #here very recently
3:06:14
beach
ealfonso`: Yes, there is no standard way of creating a function with dynamic extent. If you do it with a macro that changes the FDEFINITION, then make sure you have an UNWIND-PROTECT that sets it back.
3:13:52
loke
oni-on-ion: Also note that you really don't want to be running more than one thread while doing that trick.
3:16:03
loke
oni-on-ion: You can implement it by having a single constant replaced version of the function in question, and you setf the fdefinition of it in the beginning. Then, inside that function you check a thread-local binding of a variable that indicates which version you want and if it's unset, just forward the call to the real (original) version.
3:18:44
loke
I just remembered I did something similar in Climaxima when I want to change the behaviour of some internal Maxima functions
4:08:51
beach
DecimPrime: Though, people here are less likely to read that book than they are to read books like PAIP, AMOP etc., since this channel is dedicated to Common Lisp.
4:14:30
DecimPrime
beach: hah. ahh i see. i'm mostly using clojure but i just heard it was great for learning how to break down and solve problems so i'm going to look through it
4:16:19
beach
DecimPrime: And I am guessing the advocate a more "pure" style of programming, like more functional programming, more recursion, etc.
4:16:59
beach
The Common Lisp books are typically more pragmatic. And modern Common Lisp uses object-oriented programming (using CLOS) a lot.
4:29:59
no-defun-allowed
I want to find some inputs to imagemagick that will help me clean up captchas to give to tesseract-ocr. They have added noise that needs to be filtered out.
4:30:45
oni-on-ion
i was just reading about the first FPGA chips and how they were 'evolved' (1960s)
4:32:30
jcowan
beach: HDTP teaches elementary computer *programming*, whereas SICP teaches elementary computer *science*. Both of them use Scheme because of its simplicity and closeness to mathematical notation.
4:39:19
beach
jcowan: Still, my guess is that the programming style is going to be influenced by the convictions of the authors. But I should quit guessing and read the book instead.
4:39:42
theemacsshibe
for example, call-cc and macros aren't touched on since they don't really do much for the first few chapters
4:40:04
jcowan
Well, certainly. Indeed, I know of no textbooks whatsoever that are not influenced by the convictions of their authors1
4:40:54
theemacsshibe
MIT released recordings of the relevant lectures, too. each is an hour long in three 20-minute segments.
4:42:30
DecimPrime
jcowan: i see. i had and liked what i read of SICP. someone stole my book. i'll have to finish it off later on.
4:43:34
jcowan
Again, it's about *elementary* programming. The authors found that SICP gave insufficient attention to the problem of learning to produce a formalism that represents an informal intention.
4:44:36
DecimPrime
i've toyed with several languages...self taught but never got into meat of completing something. largely because i felt i've missed out on breaking things apart...which lisp in its self has helped out a lot with
4:44:56
jcowan
which is kind of like teaching singing by saying "Sing!" and then trying to help the people who sing -- it does nothing for the people who don't.
4:45:04
beach
There are a certain number of books that claim to do that, but in fact, many of them are hailed by colleagues with decades of experience as being exactly what is needed, but they make no sense whatsoever to the intended audience.
4:45:41
jcowan
I am not necessarily defending HTDP, as I have not read it either, just explaining what I understand its purpose to be.
4:46:38
beach
jcowan: Math is taught the same way. Students are shown lots of proofs, but no way of coming up with their own. They are supposed to generalize from examples.
4:49:58
jcowan
"The first and best way to solve ODEs is to guess the answer and see if it's right. If this fails, integrate both sides if you know how. Otherwise go to the Taylor expansion. If you can't solve it by any of these means, you probably can't solve it at all."
5:29:03
no-defun-allowed
unfortunately it seems my combination of tesseract and imagemagick switches only gets 2/5 chars right
5:32:05
lucca
There are more techniques for integration than grains of sand in all the beaches of all the worlds of the galaxy. Finding them is left as an exercise for the reader.
5:33:06
LdBeth
just found a really interesting thing https://liu.diva-portal.org/smash/get/diva2:256466/FULLTEXT03.pdf
7:56:50
beach
The other day, jackdaniel showed me this PDF of some slides from a talk by Rob Pike: http://doc.cat-v.org/bell_labs/utah2000/utah2000.pdf
7:57:40
beach
Perhaps some people will think I am less crazy for suggesting CLOSOS when they see that even very famous people think that it's a good idea to attempt to create new operating systems.
8:01:10
beach
There was a lot of innovation back then, and, as Rob Pike admits, Unix killed all innovation.
8:02:42
DecimPrime
=P well CL has been around for much longer. but still yes suprised it's so lively at this hour
8:03:08
beach
It slows down during the weekend. I suspect many people here have a real life as well.
8:04:13
DecimPrime
i have insomnia so i like to talk to people fom europe etc...they're up but still not as lively in certain rooms
8:05:09
beach
DecimPrime: #lisp is know to be active, and also very helpful, even to newbies (provided they take the advice they are given).