libera/#commonlisp - IRC Chatlog
Search
4:22:39
hirez
it was 110 degrees F today here in the southwest states. Hows the weather on the other side of the pond.
4:23:15
Colleen
Weather in Bordeaux: Partly Cloudy at 13°C, 100% humidity, 1km/h wind, 1023hPa pressure.
4:24:51
hirez
hah, that isn't too bad 80 deg in freedom units at 100% humidity seems kind of muggy though
4:27:19
hirez
bordeaux huh. Never heard of it. You can tell how cultured I am. Looking at a map it seems adjacent to a river of some kind so the high humidity makes sense.
4:28:40
hirez
I believe it. My girlfriend is an amateur chef that refuses to open a shop. She studies from french cookbooks.
4:44:05
beach
I'll make a "magret de canard" for your girlfriend. Served with a "Pessac Léognan" red wine.
6:11:56
edgar-rft
places in the world named Bordeaux -> https://geotargit.com/called.php?qcity=Bordeaux
6:50:33
hirez
I am trying to pass a lambda into the sort function. I need to preload the lambda with a start point to do angular sorting.
6:51:12
hirez
when I let bind the function it (as expected) wont let me pass it into sort with #'my-func
6:51:40
hirez
(if you're wondering this is the preamble code for graham's scan - a famous algorithm for computing the 2d convex hull in O(nlogn))
6:53:19
White_Flame
sort-func is a plain variable, holding a function object. just pass that value to sort
6:53:59
White_Flame
if you had (let ... (defun sort-func ...)), or (labels ((sort-func ...)) (stable-sort ...)), then you would use #'sort-func
6:55:18
White_Flame
right, the lambda object directly gives you the function object value, and you don't need to look it up by function name somewhere to extract the function objec from some (my-sort ...)-callable named functino
6:55:48
hirez
Oh I see, so you can sort of think of #' as a nice macro to "extract" the function from the definition table
6:56:12
White_Flame
DEFUNs are global function definitions, FLET/LABELS are local function definitions
6:56:54
hirez
I see, yeah it was mostly just a convenient way to think of it. I suppose "extract the function from the known function labels" would be more accurate.
6:58:05
White_Flame
so you can't do (let ((list '(1 2 3))) ...) because that would override the CL:LIST function!
6:58:56
White_Flame
and why Scheme has to do the equivalent of (let ((lst ...)) ...) to avoid collision
6:59:23
hirez
Ah I see, so there's a function namespace and variable namespace in lisp2 and in lisp1 they are the same
6:59:47
White_Flame
there are way more namespaces in CL (like 7+), but those 2 are the main ones in this respect
7:00:49
flip214
or perhaps #' vs. symbol-value, though this isn't right because of lexical bindings either
7:28:21
beach
hirez: Also, there is no such thing as "a lambda" in Common Lisp. There are anonymous functions that are typically created from the compilation of a "lambda expression". In many other languages, anonymous functions are a recent invention, so they gave them the name "a lambda", but in Common Lisp, they are not a big deal, and in fact, DEFUN can very well expand to a lambda expression.
10:42:51
pjb
beach: it's the opposite. Here in France, there are many foods named after their place of origin!
10:45:28
pjb
hirez: have a look at: (lisp1-vs-lisp2) http://www.nhplace.com/kent/Papers/Technical-Issues.html
11:30:19
jcowan
White_Flame: I wish CL people would stop spreading the error about not being able to use `list` as a variable in a Lisp-1. The only time you can't do that is if you want to call the global function `list` in the same scope.
11:37:12
edgar-rft
pjb: there is a place named Pizza in Nigeria -> https://geotargit.com/called.php?qcity=pizza
11:37:13
dsk
(let ((list (list 1 2 3))) list) actually works fine in Scheme, so it's not the best example.
11:37:31
splittist
I guess most times one wants a variable named list would not include use of the function list. On the other hand, a large proportion of the times you would use the function list you would want a variable that is a plain list. OTOH, this comment is probably longer than the amount of Scheme I have written in anger.
11:38:33
jackdaniel
dsk: the point of the example with list is that you can't do: (let ((list (list 1 2 3))) (list '(3 2 1) list))
11:40:35
jackdaniel
looking at things from the other side of the wall: schemers take pride in macro "hygiene" (and claim that cl macros are inferior), but avoiding organic macro pitfails is easy with gensyms and once-only operators while cl macros are much "natural" to use (at least to me)
11:41:59
dsk
Yes, normal DEFMACRO macros are much easier to write and debug than e.g. syntax-case ones.
11:42:26
jackdaniel
Inline: macros are in the same namespace as functions but are treated differently by the compiler
11:42:51
Inline
apart from that i find that when you are on a DSL level of cl those macros don't work anymore when the DSL doesn't allow for it
11:49:15
jcowan
In addition, the gensym solution is only half hygienic: it protects the caller from the macro, but does not protect the macro from the caller
11:50:53
jackdaniel
jcowan: in practice cl macros are just fine and easier to use, so one could turn the table and say, that "hygiene is contrived. 90% of the time there is no [need for protection] and the remaining parts are easy to fix"
11:51:46
jackdaniel
either way, all these arguments boil down to "mine is better because it is miner"
11:52:34
jcowan
But if you are going to do advocacy, it's important to understand what you are advocating against (as we see in politics)
11:54:06
jackdaniel
I wouldn't attempt such wasteful thing as advocacy (or politics); I'll get better back to work ;)
12:05:44
scymtym
the limitations or macro lambda lists seem like a bigger practical downside of the CL macro system to me
12:11:17
pjb
scymtym: what limitation? Macro-functions take whole forms, they can analyse the lambda list as they wish!
12:14:27
scymtym
pjb: yes, but for syntax expressed in the macro lambda list, there are several benefits. for once, a user can more easily introspect the syntax of the macro. also, the implementation can do a better job of reporting syntax errors without the need for the macro writer to use WITH-CURRENT-SOURCE-FORM or something similar. an example of syntax that cannot be expressed in a macro lambda list is the "options" syntax that is used in
12:15:49
scymtym
pjb: note that i didn't say CL macro were limited. i said macro lambda list have limitations
12:16:52
edgar-rft
pjb: Modern humans once came from Africa, where Pizza/Nigeria obviously is the place where the Italians came from.
12:25:49
pjb
scymtym: Yes, I understood. For functions, we also have &rest arguments, and specific parsing. It's obvious that lambda-lists have a restricted grammar and cannot parse any language. (I like to write my command options/arguments parsing using sophisticated (english-like) grammar, but it's not the unix concise style for command options).
12:27:17
pjb
scymtym: but it wouldn't be efficient, or easy to use, if each operator definition had to provide a grammar for its arguments parsing. We want a limited set here. (but lisp is smart in allowing general parsing thru &whole or &rest).
12:30:13
scymtym
pjb: sigh. i know that things are the way they are for a reason. i'm not going to debate this further