freenode/#lisp - IRC Chatlog
Search
6:04:37
aeth
In general the differences are: Scheme is (1) minimalist (and breaks compatibility so the names are often cleaner), (2) has hygienic macros, (3) has call/cc, (4) guarantees tail call optimization so tail recursion is idiomatic
6:05:13
aeth
Scheme implementations are incompatible with each other in key areas (although portable Scheme is possible to write).
6:05:50
aeth
Common Lisp culturally values portability, is more of a practical language instead of an academic one (at least traditionally), and has a huge immutable standard.
6:07:38
aeth
I think that the main practical use in modern programming style would be trivial coroutines? https://en.wikipedia.org/wiki/Coroutine#Implementations_for_Scheme
6:09:35
aeth
But I think a good distinction that hints at the early 1990s era cultural divide (practical vs. academic) is that if you're working with arrays of numbers, CL is imo much nicer than Scheme.
6:14:17
aeth
(And I wouldn't be entirely surprised if some Scheme implementation eventually extended the numeric tower to include all division algebras, not just real and complex)
6:23:32
beizhia
I can see why a scheme-type language would be nice for something like Guile, where you only want to embed as little as possible. For something on its own though, common lisp just feels much more usable.
6:24:44
fiddlerwoaroof
ACTION likes how CL feels like it could be an OS if people were willing to give it a chance
6:26:44
fiddlerwoaroof
Anyways, I put together a little demo that uses custom method combinations to define groups of HTTP server routs: https://gist.github.com/fiddlerwoaroof/2def4b081bb9ba179efcce48a204646c
6:27:31
fiddlerwoaroof
It works in Lispworks and ECL, but sbcl and ccl seem to have a bug in their implementations of define-method-combination's long form that prevents it from working there.
6:31:43
fiddlerwoaroof
And, there's also a question of whether or not my method-combination is conforming
6:47:11
beach
I just thought of a way, and it is so obvious that I am convinced that SBCL already does it in a similar way.
6:48:21
fiddlerwoaroof
I have a hazy recollection of reading a comment about this last night, but I was focusing on other things
6:50:26
aeth
fiddlerwoaroof: If beach doesn't know something about the implementation of CLOS, there's a good chance no one knows.
6:55:08
jackdaniel
I believe you don't give enough credit some prominent figures in the community (which I won't call by name to not embarass them with such praise :)
6:57:26
jackdaniel
that's not the point. there are many people who worked on existing implementations or compared them. for instance at last ELS the very topic of method combinations has popped up
6:57:55
fiddlerwoaroof
And, this isn't a question of implementation but of the interpretation of the standard
6:58:18
fiddlerwoaroof
The standard is vague about what happens when all the specifiers match but the qualifiers differ
8:39:15
heisig
mrblack: But it is not a function, it is just a symbol that is treated specially in certain macros.
8:39:43
mrblack
jackdaniel, heisig: cool, thanks... it was used in Land of Lisp but I don't think the author explains it, couldn't find. It's hard to find info about it because that's a common word. Do you have any links for it?
8:40:35
jackdaniel
use l1sp.org (the second character is "one", not small "L"), very handy for such lookups
8:40:38
mrblack
thank you, jackdaniel. this seems like a good site to bookmark. Google wasn't of much help ;)
8:41:19
jackdaniel
also I believe that duckduckgo redirects to this site when used with a special bang
8:41:48
aeth
If you make DuckDuckGo your default search engine you can just !l1sp in the URL bar in e.g. Firefox
8:42:03
mrblack
jackdaniel, aeth, great. I used Vimium, though, it lets me create commands for any search I want.
8:45:13
mrblack
is it possible to access this documentation offline like man pages, from Emacs or the command line?
8:46:52
mrblack
I see that "slime-documentation-lookup" will open the term under cursor on the web browser... it's good enough, I guess. But offline would be better
9:24:31
Xof
fiddlerwoaroof: I think you've found the two relevant paragraphs about method combinations and matching specializers / differing qualifiers
9:25:25
Xof
sbcl generally (at least historically) tends to go for outward portability -- if it uses only standard functionality and runs on sbcl, it runs on other CLs
9:25:42
Xof
so it chooses to obey the paragraph that says that what you're trying to do isn't allowed
9:26:07
Xof
however: there is an escape hole -- sbcl doesn't enforce that restriction if there is a single, wild-card method group
9:30:33
Xof
beach: sbcl optimizes make-instance in a bundle of different ways. the main way is when the initarg symbols are constant, we construct a CTOR (see src/pcl/ctor.lisp) which maps the initargs to slot locations (per-class if the class-name argument to make-instance is variable, otherwise just once), receives values for all the initarg forms that weren't compile-time constants, and allocates and initializes the instanc
9:30:52
Xof
actually I'm less sure about the "bundle of different ways"; I think I've managed to get them all into one sentence :-)
9:31:45
beach
Xof: Thanks. What if there are :AROUND methods on INITIALIZE-INSTANCE and/or on SHARED-INITIALIZE?
9:35:36
Xof
we refuse to optimize if there's a non-standard allocate-instance method, or an :around method on shared-initialize. we can cope with :around methods on initialize-instance if it calls (call-next-method) appropriately
9:38:11
Xof
welcome. This was largely Gerd Moellmann's work, when he was (I presume) bored between jobs around *gulp* 2002
10:07:48
flip214_
Can I get the current input position (in bytes) from CXML? I'd really like to create an index (tag => position, length) into a large XML file, and then do "random" IO on it.
10:35:33
beach
You say that ASLR is irrelevant to my address-space argument. I don't understand why.
10:39:29
flip214_
beach: ASLR is irrelevant for the "historical reasons", and also " does not take great care to prevent a temporary buer from overowing,
10:43:15
flip214_
so yeah, ASLR helps _a_small_bit_ re security -- but as soon as you can overwrite a buffer or cause other misbehaviour, you more or less have lost. even if the program "only" crashes, it's a very easy DOS.
10:43:54
beach
I still think it is relevant. ASLR attempts to prevent some code from sticking a different return address on the stack by making that return address randomly different.
10:44:26
beach
And putting a different return address on the stack is possible because the process has full access to its address space, including the stack.
10:44:59
beach
So if the process did not have access to its stack, this kind of attack would not be possible and ASLR would not be necessary.
10:45:25
flip214_
beach: I thought that your main point in 1.2.4 is that full-address-space access is because of historical reasons, and has quite some security implications - some of which might get better with ASLR.
10:45:57
flip214_
but then you propose an architecture where _all_ things run in the same address space, and could potentially read each others secrets.
10:46:43
flip214_
beach: in your architecture, they won't, but that's not a feat of ASLR. _that's_ why I think ASLR is irrelevant for CLOSOS.
10:47:44
beach
It was not meant to be an argument for my architecture. It was meant to be a description of a kludge that was invented to improve security in a system where the process has full access to its address space.
10:49:47
flip214_
beach: I suggested to shorten the ASLR paragraph (and not remove it), so that it's not forgotten.
11:44:46
pillton
mrblack: You can download the CLHS from http://www.lispworks.com/documentation/common-lisp.html .
11:45:56
pillton
mrblack: In can set where emacs looks up pages by changing common-lisp-hyperspec-root i.e. (setq common-lisp-hyperspec-root "file:///my-fancy-nick/contrib/hyper-spec-7.0/HyperSpec/")
11:48:19
flip214_
when using FORMAT iteration ~:{ ~a ~a ~}, can I make the second element optional, eg. for an input '((1 2) (2 3) (4)) ?
12:04:23
mrblack
Does anyone know why I'm getting an error here? "(equal '(1 2 3) (cons 1 (cons 2 (cons 3))))". I'm using sbcl, and this is a direct copy from the book Land of Lisp (I usually type, but I copy pasted just to check after getting the error). Here are the environment and errors: https://hastebin.com/yimevowome.php
12:09:20
jackdaniel
mrblack: I'm certain that 40 people there will be more interested in basics than 316 people here
12:10:11
jackdaniel
as of cons, it is a two-argument function. lists defined recursively as NIL or cons
12:13:08
mrblack
jackdaniel, I understand that "nil" is the empty list, but what I really wanted to know is why it's necessary in the example...
14:46:17
Xof
fiddlerwoaroof: well, I'm less certain than I used to be about the outwardly-portable conservative interpretation of the spec (and other developers are more radical in various directions than I am)
14:46:40
Xof
fiddlerwoaroof: but you can make progress by making your own method combinations with the * method-group
14:52:37
mrblack
edgar-rft, I don't think I got to the "list" function with that syntax, but I get your point
16:18:28
fiddlerwoaroof
Xof: yeah, although I'd think that the same reasoning that allows * to "ignore the rules" should apply when * is part of a qualifier pattern
16:36:01
mrblack
I'm trying to understand this function: https://hastebin.com/onugivohev.pl . What is does: tells me if there's and object on a given location. I understand what "assoc" and "cadr" are doint. What I don't understand is where the value for the parameter (obj) comes from, what is its value?
16:39:31
jackdaniel
this is a good question for clschool (again ,p). remove-if-not takes two arguments: a predicate and a sequence
16:40:09
jackdaniel
then it applies each element in the sequence to the predicate (your obj), and if predicate returns T, element is kept, otherwise it is removed from said sequence
16:40:43
jackdaniel
so remove-if-not returns a sequence with all elements in it which met the predicate
16:41:09
jackdaniel
as of asking questions, sometimes it is worth waiting a little more or try things by yourself.
16:41:35
jackdaniel
mrblack: I believe reading this resource will be beneficial to you: http://catb.org/~esr/faqs/smart-questions.html
16:43:53
pfdietz
One thing to be clear about: remove-if-not is nondestructive. It does not modify its argument (although the return value may share structure with that argument).
16:44:37
jackdaniel
mrblack: remove-if-not applies function at-loc-p to elements which are in the second argument
16:45:19
pfdietz
All lisp variables can be thought of as pointers (although for numbers or characters, the things being pointed to can be copied at any time, at least conceptually).
16:46:53
minion
mrblack: please see gentle: "Common Lisp: A Gentle Introduction to Symbolic Computation" is a smoother introduction to lisp programming. http://www.cs.cmu.edu/~dst/LispBook/
16:47:18
pfdietz
What that code is doing is removing every object from the sequence objs for which the loc of that object (as defined by the association list obj-locs) is eq to loc.
16:47:35
minion
more gentle than Land of Lisp? It has cartoons: An error was encountered in lookup: Parse error:URI "https://www.cliki.net/more%20gentle%20than%20Land%20of%20Lisp?%20It%20has%20cartoons?source" contains illegal character #\? at position 84..
16:50:11
pfdietz
Could also write (remove loc objs :key (lambda (obj) (cadr (assoc obj obj-locs))) :test 'eq)
16:50:12
mrblack
anyway, what I'm not understanding is here does the "obj" the appears in the the definition of at-loc-p(obj) comes from... because it is not entered by the main function, which have these arguments: "(loc objs obj-locs)"
16:51:05
pfdietz
mrblack: that "obj" is a formal parameter of the internal function defined by the labels form.
16:51:43
mrblack
pfdietz, but what is it's value gives its value in (cadr (assoc obj obj-locs))? what does it do????
16:52:19
pfdietz
remove-if-not calls at-loc-p on each element of the sequence. For each call, obj is bound to that element.
16:52:37
pfdietz
So, if objs was the list (a b c) then at-loc-p would be called on a, then on b, then on c.
16:52:56
Bike
Okay, so say you have (labels ((oneplus (x) (1+ x))) (mapcar #'oneplus '(1 2 3))), do you know what that would return?
16:55:46
Bike
(mapcar #'1+ '(1 2 3)) is kind of like (list (1+ 1) (1+ 2) (1+ 3)); mapcar calls the 1+ function on each element of the list.
16:56:41
Bike
mapcar calls oneplus on each argument the same way (mapcar #'1+ ...) would call 1+, and puts the results in a list.
16:56:57
Bike
so (labels ((oneplus (x) (1+ x))) (mapcar #'oneplus '(1 2 3))) would also return (2 3 4).
16:57:36
pfdietz
oneplus is called more than once, and on each call 'x' is bound to a different value (1, then 2, then 3).
17:02:09
Bike
remove-if-not calls its function argument on each element of the list it's given in the same way. so that's where the obj argument comes from.
17:05:58
Bike
No. Listen. (remove-if-not #'at-loc-p objs) is a function call. the REMOVE-IF-NOT function receives two arguments, #'at-loc-p and objs. #'at-loc-p is a function and an argument. that's the "function argument" i meant.
17:06:26
Bike
So with (remove-if-not #'at-loc-p objs), remove-if-not will call the at-loc-p function on each element of the objs.
17:07:27
pfdietz
In C, you can pass function pointers to other functions. This is something like that.
17:08:47
pfdietz
#'at-loc-p is a value that can be computed before calling at-loc-p. It doesn't come from a call to that function, but rather is something like a pointer to that function.
17:10:12
pfdietz
It might be helpful to consider a case where the function being passed is defined by defun, rather than inside another function using labels.
17:10:47
mrblack
I don't know, man, this book feels a little unfair. He/She trows a of of things at me... I don't know it it's all like that. But this "recursion hell" (don't even know if that is recursion) should be better explained.
17:23:53
pfdietz
The labels form has the definition of at-loc-p, but that definition isn't invoked up there. It's just defined there.
17:24:38
pfdietz
Execution falls down into the body of the labels form, which is the call to remove-if-not. THAT function then calls at-loc-p on each element of the sequence objs.
17:25:28
pfdietz
And the value returned by the call to remove-if-not is the value returned by the labels form, and then from the call to objects-at.
17:26:36
pfdietz
A function definition, like that in labels, doesn't start executing the function, it just wraps it up in a nice package that other things can call.
17:35:38
pfdietz
One tricky thing there you should understand: where do loc and obj-locs come from inside the definition of at-loc-p?
17:36:50
mrblack
pfdietz, I think those are parameters supplied from outside the function... either user input or from another function
17:37:00
pfdietz
Those are the reasons that code is using labels, rather than defining at-loc-p outside in a defun.
17:38:18
pfdietz
So each call to at-loc-p is seeing those same two variables. Unlike the parameter obj, which is new on each call to at-loc-p.
17:40:48
pfdietz
Functional programming basically means (1) no assignment statements or other operations with side effects, and (2) using functions as values. This example is functional programming, yes.
17:42:42
pfdietz
assoc looks up an element of an association list; cadr pulls out a value from that element, and eq compares. No objects are being modified, no variables are being assigned to.
17:45:27
pfdietz
Lisp *does* support imperative (the opposite of functional) programming. It has destructive operations and assignments. But this example does not use any of that.
17:47:26
mrblack
lisp is so different it is like learning Japanese sometimes :P Only dabbled with C and Pascal before
17:49:37
mrblack
I like Pascal, but it doesn't have much use. My professor used to teach algorithms for a while (it was actually a Portuguese "translation" people here use to teach newcomers)
17:49:56
pfdietz
Lisp lets you do something new, though: you can define a function inside another function, then return it. This is illegal in Pascal; there functions can only be passed "downward" as arguments to other functions, not stored or returned. There's an implementation reason for this (not important now).