freenode/lisp - IRC Chatlog
Search
5:00:56
aeth
There's other criteria. Benchmark? Write a toy program in both and see which API feels better?
5:03:31
aeth
The license is definitely a good filter, though, I'll agree with that. I don't use anything LLGPL because it's a custom license not approved by the FSF or the OSI.
5:04:04
aeth
And you can't use any license more restrictive than the license you intend on using. AGPL is the (near) universal receiver, MIT/BSD has to be a lot more careful.
5:06:04
aeth
CL-WHO is BSD and Spinneret is MIT so essentially any program can use either (* not taking into account the unlikely event of software patents)
5:06:39
aeth
tsizz: the Wikipedia article seems to be fairly clear about it. https://en.wikipedia.org/wiki/S-expression
5:08:05
beach
tsizz: That might be because there are two meanings. One meaning is a Common Lisp data structure in memory made up of CONS cells and atoms. The other meaning is the textual representation of such a data structure.
5:08:27
aeth
I think generally the diagram used for s-expressions is box-style instead of that tree-style, though... i.e. [ * | --]->[ 2 | --]->[ 3 | \ ] for (* 2 3) with any additional nesting going on rows below.
5:09:33
tsizz
so S expression is any object or function in between paraentheses that can be broken down into cons cells and atoms?
5:10:32
beach
tsizz: Any Common Lisp data structure is made up of CONS cells and atoms. There is nothing else.
5:10:57
aeth
tsizz: Oh sorry I added to the confusion. S-expression is the notation we use to represent the cons cells.
5:11:08
aeth
tsizz: the box notation is an alternative representation, obviously a lot harder to type
5:11:50
aeth
tsizz: imagine if you had to draw this to program instead of '(42 69 613) https://commons.wikimedia.org/wiki/File:Cons-cells.svg
5:11:52
tsizz
thats what i said right? that s expression just easier way to write constant cons cells?
5:12:48
tsizz
beach: i meant instead of writting a lot of const cells u can write an easy s expression kind of
5:12:51
aeth
tsizz: the syntax becomes a linked list, which is then processed, which could create anything
5:14:00
beach
tsizz: You are in the wrong channel then. This channel is dedicated to Common Lisp, and the terminology may be different.
5:14:52
aeth
tsizz: (make-hash-table) is, at a certain stage of the program `(make-hash-table) which is roughly equivalent to (list 'make-hash-table) or (cons 'make-hash-table nil) but at runtime it's a function call that returns a new empty hash table, not a list.
5:15:49
beach
tsizz: Look in the glossary under "atom": http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_a.htm
5:15:50
aeth
and some things like #(1 2 3) or "123" are, at all times, never lists... they're atoms.
5:16:34
tsizz
someone tried to explain to me atoms are numbers, booleans, etc. then S expression are basically atoms or lists of atoms
5:18:01
tsizz
beach: im just confused as what the point of s expression is. if its a data structure like you said. it seems liek its a datatsructure holding a data structure
5:18:14
aeth
tsizz: yes, an atom is simply not a cons. http://www.lispworks.com/documentation/HyperSpec/Body/t_atom.htm
5:19:32
aeth
tsizz: There's essentially three stages going on. First you have a stream of characters. These are assigned meanings. Basically atoms or conses. And then this runs and becomes the program. So you can put a macro at either stage (the reader, or the s-expressions) to change the behavior of the earlier stages.
5:20:30
aeth
I think ( is a reader macro in Common Lisp. In fact, it looks like it is... http://www.lispworks.com/documentation/HyperSpec/Body/02_d.htm
5:20:55
Jachy
If you squint an S has a ( with a ) below it... but the s in s-exp stands for symbolic. It's just a format to represent expressions. In math you might have an expression like f(x, y) for a function call. With m-expressions you might see f[x;y]. With s-expressions, (f x y).
5:23:00
aeth
tsizz: The reason we care about if something is an atom or not is because of the stage when DEFMACRO works. The common kind of Lisp macro. A macro can take `(a b c) and turn it into something like `(setf b (* 2 c))
5:24:26
Jachy
If my text editor has (format t "Hello~%") in it, it's an s-expression, but it's not being evaluated. I can tell Lisp to evaluate it, though.
5:25:46
aeth
tsizz: Most programming languages only have strings or charcter streams to work with. This makes it hard to write programs that write programs, or to add new syntax. By writing (f 1 2) instead of f(1, 2) we have a nice, regular notation that makes it easy to add new syntax.
5:26:09
aeth
The regular notation is pretty important because we don't just have (f 1 2) we also have (+ 1 2)
5:26:28
aeth
Most languages don't do +(1, 2) they do 1 + 2. And now to extend the language completely you have to teach it both prefix and infix.
5:26:39
tsizz
mhm.. so an S expression is just any expression that fits the syntax of lisp basically..?
5:26:54
Jachy
You can do it that way, but you don't have to wrap it in a function. You can also run Lisp interactively from the console, it will prompt you for expressions to read, then evaluate, print the results, and loop back to the prompt. You'll see the phrase REPL for that behavior. You can also configure many editors to send the file contents directly to an already running Lisp process for evaluation.
5:28:18
tsizz
so s expression is any expression in lisp bc its anything that contains atoms or list of atoms and that is what everything in lisp is made out of excluding cons
5:28:41
aeth
tsizz: Well, there are other syntax elements to Lisps. In Common Lisp, you get #x42 as a representation of the number 66 in hex. That uses syntax, but not s-expression syntax
5:28:57
aeth
So atoms can have their own syntax, and they can be different in different Lisps (and other Lisp-like languages)
5:30:16
aeth
tsizz: s-expression syntax is the (a b c) as shorthand for (a . (b . (c . nil))) as well as that longer (a . b) etc. syntax
5:31:02
aeth
lists are cons cells, yes. (a . (b . c)) is also legal and that can be shortened to (a b . c)
5:31:54
tsizz
aeth: mhm but if atom is defined as anything not a cons cell, then a list shouldn't be an atom?
5:32:11
aeth
In Scheme, lists must end with '() which is their nil. In Common Lisp, dotted lists are lists, and the ones that end in nil are called proper lists. (This is a Common Lisp channel.) So in Common Lisp, lists and conses are essentially synonymous
5:36:25
aeth
'(a b c) is a proper list whose cdr is '(b c) whose cdr is '(c) whose cdr is '() or nil (both are valid representations of nil)
5:38:36
aeth
In Common Lisp, you could define listp like this: (defun listp (object) (or (consp object) (null object)))
5:40:18
aeth
Note that in Scheme/Racket list? uses the Scheme definition of list, which is proper list in Common Lisp. So (listp '(1 2 . 3)) is t in Common Lisp but (list? '(1 2 . 3)) is #f in Racket.
5:40:28
aeth
So if you're writing list? for your Scheme implemnetation it afaik has to walk the entire list
5:42:25
aeth
tsizz: In modern terminology, the thing created by (cons 1 2) is a cons, a cons cell, a cons pair, or a pair. Interchangably, really. Schemes tend to call them just "pairs" (but still create them with cons) and Common Lisp's glossary just calls them "conses"
5:44:57
aeth
Hmm, apparently they can also be called "NATSes", but I've never seen that before. Also, just plain "cells". https://en.wikipedia.org/wiki/Cons
5:46:27
beach
aeth: You should be more careful with words such as "is" and "equivalent" when you are talking to people who are learning the terminology.
5:46:29
aeth
Generally, you use ()s without quotes only in macros which in reality makes it just '() since the macro's arguments are essentially just quoted.
5:47:24
tsizz
aeth: mhm, but im confused why the distiniction of having to add '() to end of a list to make a proper list. like what for?
5:47:41
beach
But tsizz is not into evaluation yet, because he/she has not understood what an expression is yet.
5:48:08
aeth
tsizz: A proper list ends in '() but you normally don't see it. You only see its absence.
5:48:38
tsizz
beach: maybe i do haha my knowlede is a bit scattered. few weeks ago i had to do this hw and did it in racket in 2 days.
5:48:53
aeth
tsizz: '(a . (b . ())) is '(a b) and not having it, e.g. '(a . (b . c)) would make it '(a b . c)
5:51:49
aeth
in common lisp '(a . (b . '())) is (A B QUOTE NIL) instead of the (A B) you might expect
5:52:18
tsizz
but im still confused on why u have a properlist structure that is just a list that ends in nil
5:53:08
aeth
tsizz: that's so when you go over a sequence of conses, you can just look at the CAR to get all of the elements and stop when CDR is NIL
5:54:43
aeth
it's a cons, and it's a list (in Common Lisp, not in Scheme), but it's not a proper list. It's a dotted or improper list.
5:58:15
aeth
You usually do want that NIL at the end to terminate things, and having the existence of things that don't end in NIL is sort of a leaky abstraction.
6:00:28
aeth
Just remember that '(a b c) is really just syntactic sugar for '(a . (b . (c . ()))) or '(a . (b . (c . nil)))
6:12:37
aeth
tsizz: null isn't a number, it's the empty list. It's tested with null? in Racket and null or endp in Common Lisp
6:15:52
aeth
tsizz: When you iterate through a list, you start with '(a b c) then work on '(b c) then work on '(c) then work on '() updating with the cdr each time
6:16:15
verisimilitude
The end of a list being NIL is just a sentinel value, tsizz. There are some nice qualities that come about when the empty list is also the ending of a list.
6:16:28
verisimilitude
In Common Lisp, it's also the only false value; this is very convenient for manipulating lists.
6:18:05
aeth
tsizz: similarly you don't have '(1 2 3 4 '()) you have '(1 2 3 4) but iterating through it gives you '(1 2 3 4) then '(2 3 4) and eventually '() when no elements are left
6:19:47
aeth
tsizz: you're essentially moving through sublists because every list has a list as its cdr (which wouldn't be the case if lists didn't end in nil, btw)
6:23:06
aeth
tsizz: when you're iterating through a list, you normally care about the car and the cdr
6:23:29
aeth
tsizz: you're not iterating through values (unless you use something like map) you're iterating through sublists, so you have to take the car
6:25:21
aeth
I think that that will work but it's not tail recursive because the tail call is + not the function itself.
6:25:47
aeth
If you wanted it to be tail recursive you would have to build the value in another argument to make sure that the function's tail call is the function itself.
6:26:20
aeth
If you do recursion and can do tail recursion, yes, you should try to do tail recursion. In Common Lisp, it's rarer than Scheme because the optimization is not guaranteed.
6:31:49
Jachy
tsizz: You might want to go through the first chapter of this book https://mitpress.mit.edu/sites/default/files/sicp/full-text/book/book-Z-H-4.html#%_toc_start It's for scheme, but most of the lessons will carry back to common lisp.
6:31:55
aeth
tsizz: you have to pass it through and build it up through each iteration just like you're doing with the sublist. Except your answer is growing as the sublist is shrinking
6:32:33
aeth
tsizz: so (f (cdr list) (+ (car list) result)) and then at the end return result instead of 0
6:35:35
aeth
If you don't want the recursion, the do macro is equivalent to (a subset) of this sort of iteration in Scheme and near-equivalent (the edge case involves making closures) in Common Lisp.
8:00:14
splittist
I love the way search engines correct my searches for 'plump lisp'. Now I want to start a project called Botox.
8:05:05
aeth
They're better at being Ask Jeeves than Ask Jeeves ever was, but I don't want to ask natural language questions. I want to query specific terms that might be very niche.
8:11:48
aeth
If CL wasn't so niche it'd probably be very searchable because of its anti-symbolic naming conventions (except for arithmetic).
8:37:11
flip214
aeth: well, if you _know_ you're looking at standard CL stuff just bookmark http://www.lispworks.com/documentation/HyperSpec/Front/X_Mast_9.htm and be done ...
12:13:57
schweers
talx: in case you mean https://en.wikipedia.org/wiki/Cadence_SKILL, it is /a/ lisp dialect. This channel is dedicated to Common Lisp.
12:16:41
schweers
talx: no need to be sad. Common Lisp is around today and is a very good language with good, free implementations available.
12:17:26
runejuhl
I've only worked with it for a bit of debugging, and I'm happy for that.. just the idea of a `]` operator that closes all open braces gives me pain
12:20:23
schweers
In case someone wants to accuse me of arrogance: I’m sure I’ve uttered my fair share of bad ideas.
12:21:57
runejuhl
schweers: "In the second example, the "super right bracket." This simple device automatically enters enough right parentheses to correctly complete the current expression (in this case the procedure definition)."
12:22:19
runejuhl
schweers: from SKILL: A CAD System Extension Language, 1990, https://www.cs.york.ac.uk/rts/docs/DAC-1964-2005/PAPERS/1990/DAC90_266.PDF
12:24:35
runejuhl
here's a real example: https://github.com/cdsgit/cdsgit/blob/master/cdsgit-build/cdsgit.il
12:56:21
jsjolen
phoe: Not as far as I know. But I also don't know how to check. I installed slime through ql's slime helper
12:57:04
heisig
jsjolen: Have you already evaluated the macro definition, and are you in a package where this definition is visible?
12:58:13
phoe
jsjolen: (slime-company slime-asdf slime-fancy slime-indentation slime-sbcl-exts slime-scratch)
13:00:45
jsjolen
Well, still got the issue. IT works with other macros though, it's just adt:match tha tfails.
13:03:52
heisig
jsjolen: Odd. My last, desperate guess: Is there a compiler macro of the same name present?
13:50:09
jackdaniel
if anyone have some spare time in their hands I'd appreciate critical remarks on this mailbox implementation: https://gist.github.com/dkochmanski/4de37d4e7432d8d59afa7d2a64a4bb41
14:06:11
gilberth
As a matter of taste: I do not like the business on lines 81 and 82. Why not (min (mailbox-%count mailbox) (or n (mailbox-%count mailbox)))?
14:06:57
gilberth
And then the ZEROP test could be skipped. When 'n' is zero the LOOP would return NIL as well.
14:07:28
phoe
I'd also abstain from modifying the function argument and introduce a new binding instead - again, matter of taste and a little bit of debuggability
14:17:51
hjudt_
what is the best way to concatenate pathnames, or better a pathname and a string? e.g. i want to concat "~/my/path/" "to/this/file"?