lainchan / λ
Lisp General: Implementing its own Replacements
(princ tripcode) -| · 2020-10-08 20:46
This is the Lisp General, ask any and all Lisp questions here. Below is a link to the general's texts which contain many links to various books, documentation, websites, and other interesting information.
>Check the texts first:
http://verisimilitudes.net/lisp
>To foster discussion:
Which dialect do you prefer?
Do you use Emacs or a different lisp-based editor?
What was your first experience with lisp?
What have you made in lisp?
What is your favorite Lisp program?
What do you like about Lisp?
How do you think Lisp is (one of) the superior programming language(s)?
How long have you been programming in Lisp?
What are your favorite Lisp resources? Please share, preferably links!
Is Lisp your main programming language or not? Regardless, what do you primarily use it for?
What would you like to see in the Lisp general?
What was your favorite aspect of the Lisp machines?
Do you think we'll ever get something similar to the LispMs again?
What is your preferred method of documenting your code?
In the dialects that allow it, do you make many reader macros or not?
Do you use more than one dialect? What are they and which do you prefer?
What do you consider the criteria for what constitutes a Lisp to be?
What is your favorite function in your chosen dialect(s)?
Challenge:
Implement part of the standard library of your Lisp of choice and, for extra fun, do it in a way you've not seen before.
Cypher · 2020-10-08 22:38
>>21193
>Which dialect do you prefer?
Guile
>Do you use Emacs or a different lisp-based editor?
Yes
>What was your first experience with lisp?
8chan anons saying it's soykaf
>What is your favorite Lisp program?
Guix
>What do you like about Lisp?
(Parens)
>How do you think Lisp is (one of) the superior programming language(s)?
I just can feel the power of its simple syntax.
>How long have you been programming in Lisp?
1.5
>What are your favorite Lisp resources? Please share, preferably links!
Guile manual
>Is Lisp your main programming language or not? Regardless, what do you primarily use it for?
Yes, yes
>What would you like to see in the Lisp general?
Happy people posting parens
>What was your favorite aspect of the Lisp machines?
The idea of Lisp interpreter on silicon (or whatever) is interesting, but I didn't study it deeply
>Do you think we'll ever get something similar to the LispMs again?
Yes, LibreSoC (https://libre-soc.org/) dudes considered adding Lisp processor into their design
>What is your preferred method of documenting your code?
Long and self-describing names
>In the dialects that allow it, do you make many reader macros or not?
I enjoy Lisp even without macros, but I'll definitely learn using them one day
>Do you use more than one dialect? What are they and which do you prefer?
Not yet, but I plan learning Common Lisp
>What do you consider the criteria for what constitutes a Lisp to be?
I'm a simple Lisper: parens, macros and how it handles variables
>What is your favorite function in your chosen dialect(s)?
Good GNU integration
>Implement part of the standard library of your Lisp of choice and, for extra fun, do it in a way you've not seen before.
Sorry, but I'm busy with my project now, and I can't do my project now, because I'm busy with other things.
Maybe some day!
protected · 2020-10-08 23:40
>>21162
>Did you put some function
It's one line.
(format t "hello, world")
Terzibashjian · 2020-10-10 10:40
Wanna get started with Scheme, but I'm a bit lost. Should I use R7RS based implementations or R6RS? What's the difference? Also what implementations should I use? I've seen that Chicken scheme compiles to C, which seems nice.
I've previously used Common Lisp and felt it was way too bloated.
Lain Iwakura · 2020-10-10 13:40
>>21249
>Wanna get started with Scheme, but I'm a bit lost.
Check out this website, it covers some questions:
https://schemers.org/
>Should I use R7RS based implementations or R6RS?
I think no one takes "standards" seriously in the Scheme world.
Usually R6RS should be enough and what you care about are SRFIs:
https://srfi.schemers.org/
>What's the difference?
I didn't dive deeply into RnRS.
>Also what implementations should I use?
There isn't one answer to this question, but you should ask yourself what do you want to use Scheme for.
I use Guile, because it is what is used by the GNU Project.
Some people find Racket good, because it has a good IDE support and a picture language, but it is rather a new dialect than a Scheme implementation.
Some people like Chicken, because it has eggs.
Chez scheme is a good and fast compiled Scheme implementation, but it has bootstrapping problem - the compiler is self-hosted (also written in Chez).
>I've previously used Common Lisp and felt it was way too bloated.
Well, using Scheme made me think it lacks some features compared to Common Lisp and this is a big problem - since the language lacks some wanted by all features, different Scheme implementations add the features by themselves and what you end up with are incompatible dialects.
Wirth · 2020-10-11 03:34
>>21249
I used DrRacket (with Racket)
Probably the most fun I've had programming till date
Gyula Kovacs · 2020-10-11 04:10
>>21272
Word. Racket really is a joy.
Hououin Kyouma · 2020-10-11 22:30
>>21272
>>21275
Racket is fantastic, but I wouldn't really recommend it if you want to learn Scheme. It's deviated far enough from Scheme that it's basically it's own thing at this point.
Rick Deckard · 2020-10-12 16:08
I'm a first year undergrad student in CS, and I'm learning the Racket teaching language from htdp.org at uni. How does it compare to OG lisp?
Should I start learning lisp? I know I'm not learning "real" racket, but would the teaching language help me even if a bit?
Erik Johansson · 2020-10-12 22:51
>>21336
You're really lucky, I wish I got to use Lisp at uni instead of 4 years of C++.
All Lisps are basically similar, if you know one it's trivial to learn the others by knowing the differences. If a programme in CL looks significantly different to the same one in Scheme it's usually because of stylistic conventions, rather than actual capabilities in the language. That applies to programming languages in general too; they're typically designed to elegantly express certain concepts over others, don't be afraid to learn a new one if it can make your life easier. It's not hard to pick up a new language once you have a good mental model of computation and Lisp is a great way to learn that.
Aristóteles Amadópulus · 2020-10-13 01:58
>>21351
In the first year I'm learning C, Racket and some assembly.
I don't know when I'm going to start learning OOP, since this isn't a programming course I think I'll learn only a few other languages.
About Lisp, should I learn Lisp itself or a dialect of it? If so, which one would you recommend?
cddr · 2020-10-13 08:16
last task solved is:
https://git.envs.net/mpech/tankf33der/raw/branch/master/rosetta/esthetic.l
You could be interested in check new implementation:
PicoLisp on PicoLisp on LLVM-IR:
https://github.com/picolisp/pil21
Dozer · 2020-10-13 08:41
>>21361
That's a great mix. I had 1 course each in Scheme (using SICP!) and assembly, but all the others were C++.
There's no 1 `Lisp' unless we're talking about Lisp 1.5 back in the 60s. Common Lisp, Scheme, Clojure, Racket are all dialects in the Lisp family, in this case you can think of a dialect as Lisp lingo[0] for language in the same way C and C++ are separate languages.
Stick with Racket since you're already using it in school, it's a really fun, practical language. It'll be easy to pick up other Lisps later on if you want to dive deeper.
[0] Lisp has a lot of unique jargon.
renames · 2020-10-13 08:45
>>21374
I should add, if someone refers to a language as just plain Lisp he/she almost always means Common Lisp.
Joey · 2020-10-13 22:48
Out of curiosity, why is there a surprising number of Japanese Lisp developers?
synchronized · 2020-10-14 07:33
>>21393
Most likely because of this: https://en.wikipedia.org/wiki/Fifth_generation_computer
Drifter · 2020-10-14 13:59
Does Land of Lisp teach bad practices?
Unknown · 2020-10-15 23:50
>>21403
What do you mean by bad praticeS?
Recursive symbol · 2020-10-16 08:23
Koichiro · 2020-10-17 02:05
Best way to get into Scheme as someone who already knows other programming languages? (In my case Python and Lua primarily) I'm 5 chapters into "Teach Yourself Scheme in Fixnum Days" but I'm finding it kinda hard to wrap my head around some of it.
Nguoi La · 2020-10-17 03:49
>>21448
I don't know, really, I learned Scheme via poking Guile and reading its manual. And reading the source of the few programs written in it I could find (this was before it became popular & Guix became a thing).
dictionary · 2020-10-17 10:07
>>21448
If you want to get into the right mindset try The Little Schemer. It's written as a dialogue and teaches entirely through example. It's the most fun I've had with a CS book and goes from simple lists to the y-combinator in just 200 pages.
Jane Doe · 2020-10-17 13:40
>>21448
If you're into it, try reading the R7RS/R6RS specification. If feel weird saying this, but it's really cute.
>>21454
This is also ok, but it's slow to start if you get the basics.I was already familiar with Scheme when I tried to read it, so maybe this isn't a bad idea.
Zhora · 2020-10-17 23:56
IM trying to do a recursive/applicative function to do permutation, and I have hard times here trying to fix it, I want to pick every element and attach it to the permutations of the list withouth this element, here is what i tried:
(defun permute (lst)
(cond ((null lst) nil)
((null (cdr lst)) lst)
(t (mapcar
#'(lambda (head)
(let ((subl (set-difference lst (list head))))
(mapcar #'(lambda (tail)
(cons head tail))
(permute subl))))
lst))))
Incognito · 2020-10-18 00:42
>>21460
I didn't look too close at your code, but if you're trying to do recursion Lisp doesn't have tail-call optimization.
word · 2020-10-18 01:17
>>21461
SBCL have tail-call optmization I just tested it rn now with a simple fibonacci.
Stallman · 2020-10-18 03:20
>>21461
>>21462
Basically the issue is that it's not mandated by the spec so it's up to a given implementation to decide whether or not it implements proper tail recursion or not.
setq · 2020-10-18 04:17
I got it working, its not a very "lispy" code but it works.
Btw, any tips will be appreciated.
(defun without (elem lst)
(remove-if #'(lambda (x)
(equal x elem))
lst :count 1))
(defun perm (lst)
(declare (optimize (speed 3)))
(cond ((null lst) NIL)
((null (cdr lst)) (list lst))
(t (do* ((l lst (cdr l))
(elem (car l) (car l))
(acc NIL))
((null l) acc)
(mapcar #'(lambda (x)
(push (cons elem x)
acc))
(perm (without elem lst)))))))
Neuromancer · 2020-10-18 14:02
>>21460
It's not tail recursion, permute is called for every element of lst.
>>21465
Without can be implemented easier and faster by using remove's test key, and why are you capitalizing nil? The rest isn't bad, but a bit too "triangular" when indented.
This is my attempt
(defun permutations (list &key (test #'eql))
(loop for elem in list
nconc (permutations (remove elem list :test test))
into permutations
finally (return (and list (cons list permutations)))))
Molly Millions · 2020-10-18 14:08
>>21466
I'm not sure what you were evaluating, here's my comparison:
CL-USER> (time (progn (permutations '(1 2 3 4 5 6 7 8 9)) nil))
Evaluation took:
0.194 seconds of real time
0.193832 seconds of total run time (0.172864 user, 0.020968 system)
[ Run times consist of 0.093 seconds GC time, and 0.101 seconds non-GC time. ]
100.00% CPU
446,302,952 processor cycles
41,517,056 bytes consed compared to
CL-USER> (time (progn (perm '(1 2 3 4 5 6 7 8 9)) nil))
Evaluation took:
0.367 seconds of real time
0.365863 seconds of total run time (0.295549 user, 0.070314 system)
[ Run times consist of 0.289 seconds GC time, and 0.077 seconds non-GC time. ]
99.73% CPU
846,016,816 processor cycles
172,990,608 bytes consed
Lord Nikon · 2020-10-18 19:56
>>21425
Some lispers said it uses strange convoluted solutions that aren't considered idiomatic
Unspecified · 2020-10-19 18:00
It was already mentioned in the Emacs Lisp thread, but I find it important enough to mention here:
https://emacssurvey.org
This isn't the first survey related to Lisp I've come across, but it's the first I'm mentioning here, because it doesn't seem particularly objectionable. It allows sending in responses as an email, although the underlying SMTP relays are Google, and an alternative choice is using proprietary JavaScript, but at least it's not Google's JavaScript, I think.
Anyway, I intend to answer, not liking the trend of dumbing down programs this survey could be used to justify towards Emacs. Perhaps some of us could submit our answers here, as well, attached as a file.
Demeere · 2020-10-24 23:19
>>21470
Some lispers use strange convoluted solutions that aren't considered idiomatic
cl-noob · 2020-11-03 07:30
Hello Lainons, I'm learning Common Lisp and I would like to implement a simple GUI for a very basic 2D game, what library or toolkit would you recommend?
I'd prefer one that supports both Windows and Linux, since all of my friends use Windows and I'd like to send it to them once I'm done making it
Yamaoto Toshi · 2020-11-03 12:47
>>21497
Done!
x<->y · 2020-11-03 13:19
>>21790
I'm a lisp n00b, and I second this.
Also is there any cool projects out there in clisp that I can look into?
Just another Random Lainon · 2020-11-03 13:46
>>21790
>>21799
CL-SDL you n44bs?
t · 2020-11-04 05:21
>>21193
What the fuarrrk am I missing, I'm learning CLisp and so far so great, but I am trying to make a function that selects a random item from a list except the first, this is the prototype:
(setq x '(hello how are you))
(setq y (+ (random (length x)) 1))
(setq a (elt x y))
(write a)
For some odd reason every time I run this it only prints out the last element (YOU). Should I just give up and use rest and get my life over with. That's no the point though I want to know how random works.
John Doe · 2020-11-04 11:26
>>21823
I'm not sure how Clisp works with seeds, but I could imagine that if it doesn't change, just running the program will always result in the same value for random. SBCL seems to do that too.
My tip would be to write a generic random function ("pick-element") and then a specialized "pick-but-first", that uses "pick-element". Load the code into your REPL/SLIME and then play with it. If you use Lisp like Python, Perl or other interpreted languages, you would be missing out.
Case · 2020-11-04 14:18
>>21823
>What the fuarrrk am I missing,
You are missing the part when you RTFM
Ivan Horvat · 2020-11-06 19:32
Does one "need" to know C to learn scheme/guile?
Unsigned · 2020-11-06 19:44
>>21902
No. C and Lisp are pretty much completely unrelated. I don't know what gave you the idea that you'd need to learn C before learning Scheme.
H.R. Giger · 2020-11-06 21:04
>>21903
I was "flipping through" the guile reference manual and there are quite some C references.
Thanks
Donna Hawthorne · 2020-11-06 21:06
>>21908
Guile can call C code and be called by C code. GNU designed Guile to script projects written in C. Guile works fine standalone, but there's still lots of documentation on C interoperability.
Agent Smith · 2020-11-12 20:45
Sorry if this is a basic question, but I've been reading Let Over Lambda recently and one of the points emphasized is dynamic scoping. Given that this is optimized by using the same memory location for all variables of the same name by overwriting and rewriting it (pic related), how would this work with concurrency? Specifically because now only a single closure can be active at any given time without writing and rewriting all its variables any time a thread is switched to another closure
Boole · 2020-11-13 00:02
>>22137
>how would this work with concurrency?
The standard doesn't say anything about concurrency, so expect implementation defined behavior.
https://sionescu.github.io/bordeaux-threads/threads/make-thread/
Racket has a pretty thorough description of their own model: https://docs.racket-lang.org/reference/parameters.html
Frank Garza · 2020-11-13 16:17
>>22142
I guess makes sense, but how well does this work out in the field? (i.e. do most implementations of common lisp have good support for concurrency?, do people actually make use of this when creating something intended for concurrency)
Also a bit of a general thing , but how legit is the stuff in Let Over Lambda in terms of real-world usability?
Nobody special · 2020-11-13 16:17
>Which dialect do you prefer?
Clojure. Yes, it's a lisp.
>Do you use Emacs or a different lisp-based editor?
(space)emacs
>What was your first experience with lisp?
Wanted to learn CL but had no root permissions so had to compile it myself. Was missing some libs and ended up compiling GCC just so I could compile CL. I was using Vim at the time and did not have fun. Eventually dropped it, came back to SICP some time later.
>What have you made in lisp?
Several Clojure libs, some of them even have stars in github, if it means anything nowadays besides a glorified "like" button.
>What is your favorite Lisp program?
Probably Datomic
>What do you like about Lisp?
Homoiconicity, uniform syntax, elegance, expression based
>How do you think Lisp is (one of) the superior programming language(s)?
Lisp is ultimate power. It doesn't stop you from doing anything stupid, but you can do beautiful things in it. The fact that you can add a type system to any lisp it magical in my opinion.
>How long have you been programming in Lisp?
professionally, almost two years, two more years as a dilettante.
>What are your favorite Lisp resources? Please share, preferably links!
Every Rich Hicky talk (you can just find him on youtube), clojure.org. https://download.clojure.org/papers/clojure-hopl-iv-final.pdf is very comfy.
>Is Lisp your main programming language or not?
Yes, Clojure.
>Regardless, what do you primarily use it for?
Backend work, mostly. I have some lofty ideas I'm developing to make my work easier and more expressive. We'll see how it pans out.
>What would you like to see in the Lisp general?
References for the main dialects and resources for getting started with each.
>What was your favorite aspect of the Lisp machines?
They were truly an integrated environment.
>Do you think we'll ever get something similar to the LispMs again?
I truly believe the JVM is getting there.
>What is your preferred method of documenting your code?
I'm bad at it. I just try to write good docstrings and an informative README.
>In the dialects that allow it, do you make many reader macros or not?
No
>Do you use more than one dialect? What are they and which do you prefer?
Not at the moment. Maybe I'll get back into scheme in the future to study the nanopass framework.
>What do you consider the criteria for what constitutes a Lisp to be?
Homoiconicity, some sequence processing orientation, true reader, extensibility.
>What is your favorite function in your chosen dialect(s)?
clojure.core/eduction
([xform* coll])
Returns a reducible/iterable application of the transducers
to the items in coll. Transducers are applied in order as if
combined with comp. Note that these applications will be
performed every time reduce/iterator is called.
;; transducers are an abstraction over reducing. A reducing process involves an accumulator and a reducing function which aggregates new values from a source into it. That is independent of whatever computation is being done, for example, mapping over a series, has no bearing on where elements come to or where they get accumulated into. Transducers separate the two.
St. IGNUcius · 2020-11-13 17:12
>>22148
>Clojure. Yes, it's a lisp.
smh
Hitomi · 2020-11-13 17:41
>>22149
I'd consider Clojure to be the very edge of what could be considered a Lisp. It's very different from most other Lisp dialects, but at the same time Lisp is still the most recent common ancestor.
Contrast that with something like ML, which while strongly influenced by Lisp is more so descended from ALGOL.
Unnamed · 2020-11-14 07:55
Why is it that Clojure's not considered a Lisp by some? I've never used it, all my experience is in CL plus a bit of Scheme, but Clojure does look the part from a distance.
car · 2020-11-14 08:10
>>22149
Why not? I don't get the people who say cons cells are essential for lisp. They're just a holdover from the very first hardware lisp was programmed on, especially CAR and CDR, those registers haven't existed for decades.
In the end, cons cells are a concretion, not an abstraction. If LISP is for List Processing, you can very well ask what makes a list. Is it being built of pairs, or is it satisfying an interface of having a "first" and "rest".
>>22170
my personal opinion: purists of two veins. One thinks a "proper lisp" is only lisp-2, which means scheme gets schlonged as well, the other purists think a lisp has to have cons cells, but that's programming with an implementation detail and not an abstraction IMO. FFS it forces you to "map" over different collections with different functions. What happened to "it's better to have one hundred functions operating on one data structure than 10 functions for 10 data structures"?
Cat Mother · 2020-11-15 09:07
Which implementation (of any dialect) of Lisp has the best support for libraries like ncurses, and other general libraries found in most unix environments.
Cypher · 2020-11-15 11:42
>>22212
I'm not sure, but I've heard good thing about Gauche Scheme when it comes to interop with Unix environments. Guile would also be a good contender.
Moore · 2020-11-15 18:06
Does anyone have a suggestion on a linear algebra library? There seem to be quite a few available and I'm having some difficulty selecting one: https://cliki.net/linear%20algebra Clem immediately caught my eye, but the lack of documentation, and the presumably humble comments on the quality of the software have me slightly worried. Would it be a bad idea to use this library?
Koichiro · 2020-11-15 19:30
>>22236
https://www.cliki.net/linear%20algebra
BLAS LAPACK are go to libs for scientific crowd since quiet a while, should be a lot of docs on them. But dunno how good are wrappers for them in LISP. I guess there should be some attention to them due to their popularity.
Motoko Kusanagi · 2020-11-15 22:36
Just a bit of humor on SBCL implementation.
St. IGNUcius · 2020-11-16 00:30
Just a function to catch the position of all match of a substring.
What you all think of this implementation?
(defun all-substrings (sub str)
(let* ((sub-size (length sub))
(str-size (length str))
(str-end (- str-size sub-size))
(result nil))
(dotimes (index (1+ str-end) (nreverse result))
(when (string= sub str :start2 index :end2 (+ index sub-size))
(push index result)))))
protected · 2020-11-16 02:41
Im >>22249 again, I just learned about the SEARCH function few minutes ago and tried to improve my code, but as anyoe can see Im using cons during inside the DO macro, It will be faster if I just use (push) in the body of DO instead of the following way?
I have tried both ways as follows:
(defun substrs (sub str)
(do ((pos (search sub str) (search sub str :start2 (1+ pos)))
(positions nil (cons pos positions)))
((null pos) (nreverse positions))))
(defun substrs (sub str &aux (positions nil))
(do ((pos (search sub str) (search sub str :start2 (1+ pos))))
((null pos) (nreverse positions))
(push pos positions)))
Crash Override · 2020-11-16 03:40
>>22260
I'm new to Common Lisp but in Scheme I would often do something like the following to avoid the reverse step entirely:
(defun substrs (sub str)
(let* ((head (list 'head))
(tail head))
(do ((pos (search sub str) (search sub str :start2 (1+ pos))))
((null pos) (cdr head))
(rplacd tail (list pos))
(setq tail (cdr tail)))))
Liet Kynes · 2020-11-17 17:02
I wrote two implementations of a gaussian elimination procedure the other day
using :LINEAR-ALGEBRA, and :CLEM respectively. Much of the design of these
libraries seems rather odd to me. For example they both lack the ability to
take submatricies in a manner that shares structure (just modifying the
accessor). This means to do something like mR₁ + R₂ → R₂ requires the
allocation of two new matrices R₁ and R₂, or otherwise to loop over the
indicies of the two rows yourself destroying the purpose of the library. :CLEM
has a number of other peculiarities, including an inconsistent naming
convention with no indication of which operations mutate a matrix, single
character parameter names, and limited documentation. I tried :MAGICL but it
did not run on my system, and the high-level interface is not stable anyway. I
didn't look over :LLA and :MATLISP in great detail, but it seems that they fail
to resolve the submatrix problem mentioned earlier. I'm rather new to Common
Lisp, and I've not used a linear algebra library before so I'm almost certainly
misunderstanding something, any idea what this could be? (it is also
interesting that so far as I can tell only :MATLISP generalizes to tensors.)
>>22242
This might be offensive, but I don't intended it as such. The reason I was
keen on avoiding BLAS and LAPACK was that I see these as sort of parochial
solutions. A pursuit of the universal may be especially foolish for linear
algebra, I'm unsure.
if · 2020-11-17 17:30
>>22309
you didn't precise what you are expecting exactly
typedef · 2020-11-17 17:48
>>22264
I just switched from PUSH to the usage of SETQ direct, because push implies evaluating the and LET* which is useless in my case, the other things to avoid the nreverse dont seems to improve the performance, you are consing indirectly in the call to LIST, here im consing direct in the call to SETQ. The steps to avoid the nreverse step is likely to be exactly what NREVERSE implementation does, transversing the list changing the cdr's to previous cons cell.
Output of repl:
CL-USER> (macroexpand '(push pos positions))
(LET* ((#:ITEM POS))
(SETQ POSITIONS (CONS #:ITEM POSITIONS)))
Implementation:
(defun subseq-pos (sub seq &aux (positions nil))
"Return a list containing positions of sub in seq"
(do ((pos (search sub seq) (search sub seq :start2 (1+ pos))))
((null pos) (nreverse positions))
(setq positions (cons pos positions))))
Anonymous · 2020-11-17 19:19
>>22312
>I just switched from PUSH to the usage of SETQ direct, because push implies evaluating the and LET* which is useless in my case[.]
Due to copy propagation the LET* would be removed in pretty much any decent implementation. You can't see this with MACROEXPAND because it depends on the surrounding context and because this happens after macro expansion time. If you wanted to test this you cold try running DISASSEMBLE on your previous two implementations to try to find any meaningful difference, noticing that they are the exact same number of instructions.
>The steps to avoid the nreverse step is likely to be exactly what NREVERSE implementation does, transversing the list changing the cdr's to previous cons cell.
The difference is in the traversal, by mutating the CDR to be the correct value while constructing the list you no longer need to iterate over its elements a separate time to correct the value of the CDR. The mutating remains the traversal vanishes.
>>22310
What would benefit from expansion specifically?
t · 2020-11-17 19:57
>>22313
I got your point I just moved the variable from LET* to &aux, thanks for explaining how this trick works, I enjoyed your code :)
(defun subseq-pos (sub seq &aux (head (list 'head)) (tail head))
"Return a list containing positions of sub in seq"
(do ((pos (search sub seq) (search sub seq :start2 (1+ pos))))
((null pos) (cdr head))
(rplacd tail `(,pos))
(setq tail (cdr tail))))
Batou · 2020-11-18 05:51
>>22147
>do most implementations of common lisp have good support for concurrency?
All Lisp implementations worth using support bordeaux-threads.
>>22147
>how legit is the stuff in Let Over Lambda in terms of real-world usability?
I'm not a fan of his custom macro language, but everything else looks real-world to me. Chapters 2 and 5 are the most useful. Chapter 2 allows you to see how OOP is just a weird special case. Chapter 5 helps you use macrolet.
cdr · 2020-11-18 06:41
>>22313
>What would benefit from stating what I expect from such library
... ummm, let me guess...
Drifter · 2020-11-18 15:29
>>22336
Fair enough I suppose. What I want is a sufficiently general linear algebra package to work on arbitrary fields so long as the requisite operations are defined, and also to have the library be sufficiently powerful to avoid having to violate abstraction barriers in order so have ‘non-consing’ operations. (I'm not expecting it to do loop fusion or anything like that) Ideally I'd have access to all the primitive operations you would have in your first linear algebra course, scalar-multiplication, mulitiplication, addition, subtraction, inversion, transpose, determinant, etc.
;; hypothetical ideal, no new allocation, generic, and easy to understand
(nsubtract
(nsubmatrix augmented-matrix j 0 :end-row (1+ j))
(nsubmatrix augmented-matrix i 0 :end-row (1+ i))
:scalar2 (/ (mref augmented-matrix j i)
(mref augmented-matrix i i)))
;; allocates two new matricies uneccessarily
(replace-matrix
augmented-matrix
(nsubtract
(submatrix augmented-matrix j 0 :end-row (1+ j))
(submatrix augmented-matrix i 0 :end-row (1+ i))
:scalar2 (/ (mref augmented-matrix j i)
(mref augmented-matrix i i)))
:start-row1 j :end-row1 (1+ j))
;; violates an abstraction barrier, and is not generic.
(let ((slope (/ (mref augmented-matrix j i)
(mref augmented-matrix i i))))
(dotimes (n (1+ last-column))
(setf (mref augmented-matrix j n)
(- (mref augmented-matrix j n)
(* slope (mref augmented-matrix i n))))))
At this point the primary features I'm interested in is
Fair enough I suppose. The main thing I'd like is a way to
What I would like is a library which provides support for sufficient linear algebra operations such that I can
Milner · 2020-11-18 15:31
>>22344
Sorry about the random gibberish at the end, I tend to write out a few sentences in pieces before consolidating out the full post. My scratch space just scrolled off screen and so I posted anyway. ))
J.C. Denton · 2020-11-20 20:38
>>22344
This isn't at all what I was asking for but I've been playing with :PETALISP and it's really enjoyable. It's not a linear algebra package at all, but rather an array programming language. I haven't fully grasped the programming model but it seems like something fun to learn from.
>>22314
I forgot that RPLACD actually returns what it sets, so we could actually do the following stylistic change if you're interested:
(defun subseq-pos (sub seq &aux (head (list 'head)) (tail head))
"Return a list containing positions of sub in seq"
(do ((pos (search sub seq) (search sub seq :start2 (1+ pos))))
((null pos) (cdr head))
(setq tail (cdr (rplacd tail `(,pos))))))
Ishikura "Tatsu" Tatsuhiko · 2020-11-21 07:13
Is ending a line with ))))) a sign of fuarrrking up code division or normal happening in bigger LISP codebase?
John Doe · 2020-11-21 08:32
>>22212
Rather than deign to use Ncurses, I've written two libraries for controlling terminal devices which may be found useful:
http://verisimilitudes.net/2017-12-31
http://verisimilitudes.net/2018-04-04
>>21823
I'll rephrase that: (write (elt #0='(hello how are you) (1+ (random (length #0#)))))
Now, in just testing this repeatedly, different results are achieved, but it should also be noted there's an error lurking as an invalid index. This lacks the flaw:
(write (elt #0='(hello how are you) (random (length #0#))))
An array is indexed from zero, so its final valid index is one less than its length, making any incrementing unnecessary. As for RANDOM, look into *RANDOM-STATE* and MAKE-RANDOM-STATE.
Random · 2020-11-21 14:24
>>22390
>Is ending a line with ))))) a sign of fuarrrking up code division or normal
Only 5 closing parentheses? I don't even see what the issue is.
>>22314
>>22384
Most people would use (setf (cdr ...) ...) instead of rplacd. And I think that (list pos) is a bit nicer than `(,pos), but maybe that's just the Schemer in me complaining.
Jens Hansen · 2020-11-21 14:52
>>22393
>Most people would use (setf (cdr ...) ...) instead of rplacd. And I think that (list pos) is a bit nicer than `(,pos), but maybe that's just the Schemer in me complaining.
I agree that (list pos) is cleaner than the quasiquotation, and mutation on quasiquoted expression still triggers alarm bells for me. I only introduced RPLACD, and SETQ in >>22264 so that I can gain better familiarity with them and decided whether I agree with the culture about the superiority of SETF; I still haven't decided.
limited · 2020-11-21 20:11
Which is better for someone no previous exposure to Lisp: Land of Lisp or Practical Common Lisp? I.e. which presents the techniques, practices, and mindset of the language more clearly?
Torvalds · 2020-11-21 21:44
>>22390
If your lines don't end like that you're doing something wrong.
quote · 2020-11-21 22:32
>>22390
It's normal in anything bigger than hello world, frankly. Just skim through the examples in any lisp textbook, you'll have trouble finding examples that don't end like that.
Haruyoshi · 2020-11-22 00:25
>>22398
>If your lines don't end like that you're doing something wrong.
Why is writing readable, well partitioned code wrong in LISP?
progn · 2020-11-22 00:52
>>22384
Using the return of rplacd seems good I will adopt this one!
>>22393
I changed the (list.. for the ` in the response of the other guy, it can cause some trouble like using returning literal defined list and changing it later?
Wintermute · 2020-11-22 03:48
>>22406
>it can cause some trouble like using returning literal defined list and changing it later?
In Scheme mutation of quasiquoted expressions is undefined. I'm almost completely certain that it's fine semantically in Common Lisp, with any disagreement on this point being stylistic. Schemers are natrually going to prefer the things they're used to, I don't think there is any rational justification for the use of LIST over quasiquotation beyond this, although it is still my preference for the moment.
Drano · 2020-11-22 09:27
>>22405
This question feels like a jab so maybe I shouldn't take it too seriously but I'll take a stab at it. Assume that you're trying to write a function in scheme that parses an integer and returns the integer and the part of the string after the integer that was parsed. For the recursive version it returns the integer and the rest of the list of characters after the integer. For the iterative version it returns the integer and the index right after the integer in the string.
(define (char-digit? char)
(or
(char=? char #\0)
(char=? char #\1)
(char=? char #\2)
(char=? char #\3)
(char=? char #\4)
(char=? char #\5)
(char=? char #\6)
(char=? char #\7)
(char=? char #\8)
(char=? char #\9)))
(define (char->digit char)
(cond
((char=? char #\0) 0)
((char=? char #\1) 1)
((char=? char #\2) 2)
((char=? char #\3) 3)
((char=? char #\4) 4)
((char=? char #\5) 5)
((char=? char #\6) 6)
((char=? char #\7) 7)
((char=? char #\8) 8)
((char=? char #\9) 9)))
;returns the integer, the exponent of the next digit, and the rest of the list of characters
(define (parse-int-rec chars)
(if (or (null? chars) (not (char-digit? (car chars))))
(values 0 0 chars)
(let ((digit (char->digit (car chars))))
(call-with-values
(lambda () (parse-int-rec (cdr chars)))
(lambda (int exponent rest) (values (+ (* digit (expt 10 exponent)) int) (+ exponent 1) rest))))))
;returns the integer and the index of the string just past the integer
(define (parse-int-iter str start)
(define end
(do ((i start (+ i 1)))
((or (= i (string-length str)) (not (char-digit? (string-ref str i)))) (- i 1))))
(do ((i end (- i 1))
(exponent 0 (+ exponent 1))
(int 0 (+ (* (char->digit (string-ref str i)) (expt 10 exponent)) int)))
((= i -1) (values int (+ end 1)))))
A few example runs:
> (parse-int-rec (string->list "100 50"))
100
3
(#\space #\5 #\0)
> (parse-int-iter "100 50" 0)
100
3
The algorithm in this case isn't super important, the point is that the shape of the code is different. In the recursive version the return values start at the end with the base case (values 0 0 chars) and get moved up the inductive step (lambda (int exponent rest) (values (+ (* digit (expt 10 exponent)) int) (+ exponent 1) rest)). This creates code that is more split up and less blocky. On the other hand the iterative version is very blocky because the problem is conceptualized in terms of steps. It starts at the end character digit of the integer and moves back a step each time. Although it still uses a lot of parenthesis because scheme is a parenthesis heavy dialect. By well partitioned I'm assuming that you mean uses the same level of indentation for a section of code. The nonblocky way of writing recursive code isn't the only way though. In terms of semantics I prefer using composition of combinators to break up the nonblocky parts of the recursive code and in terms of syntax I like the idea of something similar to haskell's do notation. You can look up how to do parsing in haskell to get a sense of what I'm talking about. Overall I think lisp is a better language than haskell, and I don't think that it's wrong or ugly to break up the indentation and have a lot of parenthesis but I still find myself wanting the terse blockyness of haskell's do notation.
Unnamed · 2020-11-22 22:35
The pathname programminga API from common lisp is still needed acctually? I just come across this one in a chapter about portable pathname in the book Pratical Common Lisp, he just give a implementation to deal with the most used implementations.
Idk if it is just a first impression on me, but this "make-pathname" and companions functions to deal with files/directories seems to be more a problem than a useful abstraction.
Scheme have something similar to this or all the implementations have a unified API which is really portable?
pop · 2020-11-22 22:54
>>22415
My main issue working with not mine [Whatever] LISP code ages ago was that after closing parentheses count goes above 5 I cannot count them just by looking at them. It's annoying to spend literally minutes just because you want to introduce some change in code that would for example require inserting some code somewhere between these snake tail loooooong elements. It was driving me crazy. Typically many of such issues could have been avoided by moving nesting blocks of code into separate entities and call them later in other places even if that meant separation just for sake of calling these fragments only once in whole codebase.
Lukasiewicz · 2020-11-23 02:46
>>22430
This problem is entirely solved by using a decent editor. I the case of Lisp that's almost always Emacs.
Ivan Petrov · 2020-11-23 07:05
>>22436
>>This problem is entirely solved by using a decent editor.
Shit XML crowd says
St. IGNUcius · 2020-11-23 08:04
>>22445
Does that matter if it's true?
Using the right tools for the right job isn't some revolutionary notion.
BloodCat · 2020-11-23 17:03
>>22446
Is there a good way to reduce the amount of nesting in LISP code?
I guess one way to handle the close parens problem would be to treat them like C closing braces, but that would take up a lot of vertical space.
Nell · 2020-11-23 17:14
>>22458
Deep nesting might be an indication that there is some abstraction to reify, but there is nothing wrong with it in its self. There is no “close parens problem”, the Lisp culture is correct on this point.
progn · 2020-11-23 17:39
>>22459
The "close parens problem" I was referring to was just unclear closing delimiters. Though you can use your editor to highlight the opening parens, it's not necessarily clear on first glance which delimiters go together. It'd be nice if there was a way to make them clearer without needing to manually highlight them.
word · 2020-11-23 18:03
22461
>It'd be nice if there was a way to make them clearer without needing to manually highlight them.
I misunderstood you as making claims about the language rather than looking for help, sorry about that. It's not exceptionally common, but some people use rainbow-delimiters for this. Most people just avoid counting parenthesis entirely, letting the machine handle things with paredit or similar.
Dujour · 2020-11-23 18:23
>>22458
> I guess one way to handle the close parens problem would be to treat them like C closing braces, but that would take up a lot of vertical space.
This is usually a sign that someone has just started using Lisp, and is seen as a sign of inexperience.
Reducing nesting is usually a design-issue, not a syntactic one. You can use different constructs, refactor functions, use local functions, etc.
>>22461
Why should it matter though? Highlighting can help, but the real help that Editors like Emacs provide is the manipulate the code not only on a line or charachter basis, but using structures, or s-expressions in the case of lisp. Most of the time, if you see someone who's code ends with ")))))))))))", they aren't even thinking about it, because their editor is taking care that it does what it should, and that the indentation reflects this.
Anamika · 2020-11-23 19:17
>>22465
need of syntax highlight is a sign of immaturity as a programmer
x<->y · 2020-11-23 19:22
>>22468
If you depend on it, yes, but it usually does make things easier, even if you can get by without it.
list · 2020-11-24 00:07
>>22333
Thanks for the answer
Wintermute · 2020-11-28 00:05
Is it possible to make a method which is variadic and where the variadic parameter can be any one of a number, array, or an instance of a class to specialize on? The best solution I've found is to specialize before the variadic parameter:
(defmethod a (function (variable discrete) &rest other) "...") This unfortunately constrains the ordering of the parameters in a way I find undesirable. It also seems to mandate the creation of a method which is unspecialized, or specialized on number, and array to cover the cases where the generic function dispatches on these built in classes.
Additionally is anyone aware of an algorithm to efficiently in space, and reasonably in time take an array of floats and return two arrays of the unique elements and their associated frequencies. I'm looking to rewrite my naive statistics package, and it seems that representing data-sets not associated with some other data-set in this way would be more efficient, so long as the conversion could be done reasonably.
Zuse · 2020-11-28 04:13
SHare your tips on how to implemet a function to generate all possible n-sized tuples using a giving domain given as a list.
Here is my atempt which works but I know is full bloated, Im using 2 separated helper functions which does almost the same things but one with cons and other with list.
(defun mul-lst (l1 l2)
(let ((lst nil))
(dolist (a l1 (reverse lst))
(dolist (b l2)
(push (list a b) lst)))))
(defun mul-lsta (l1 l2)
(let ((lst nil))
(dolist (a l1 (reverse lst))
(dolist (b l2)
(push (cons a b) lst)))))
(defun tuples (n domain)
(cond ((zerop n) nil)
((= n 1) domain)
(t (do ((result (mul-lst domain domain)
(mul-lsta domain result))
(counter (- n 2) (1- counter)))
((zerop counter) result)))))
nil · 2020-11-28 09:32
>>22458
Besides other replies regarding design, threading macros can help with that, too. I don't know if all dialects have them, but they're very easy to define. See https://clojuredocs.org/clojure.core/-%3E
Miho Iwakura · 2020-11-28 15:44
>>22614
Here's my take on the matter. It's the same implementation really, I just used the built in list iteration procedures. For reasons unknown to me my implementation seems to have memory performance which is better by a constant factor of two. Anyone know why that might be?
(defun cons-each (heads tails)
(mapcan (lambda (tl) (mapcar (lambda (hd) (cons hd tl)) heads)) tails))
(defun tuples (n domain &aux (result (if (zerop n) nil (mapcar #'list domain))))
(dotimes (i (1- n)) (setq result (cons-each domain result)))
result)
Hououin Kyouma · 2020-11-28 18:05
>>22641
I dont know why it should have better memory performan, Im the one which posted the first version, BTW thanks for catching my error, My n=1 case is wrong and you can see clearly why I did all this mess haha, my "base" case will never work good with a single function.
Reading your initialization of result as an &aux parameter I noticed my error, thanks for this!
I moved the result to be the return clause of dotimes in your code, it its not a improvement but make it 1 line short.
(defun tuples (n domain &aux (result (if (zerop n) nil (mapcar #'list domain))))
(dotimes (i (1- n) result) (setq result (cons-each domain result))))
The Oracle · 2020-11-28 18:26
>>22647
No problem about the error; I thought about saying something, but thought I'd let the procedure speak for itself. I wasn't aware of the result-form of DOTIMES, and it wasn't included in my notes anywhere. Thanks for sharing this.
roll · 2020-11-28 18:57
>>22641
>For reasons unknown to me my implementation seems to have memory performance which is better by a constant factor of two.
I figured this out, it's because you're using REVERSE instead of NREVERSE, switching to the non-consing version results in equivalent memory performance.
Yamaoto Toshi · 2020-11-28 19:00
>>22649
You actually don't need the NREVERSE at all, which would give you a benefit in time as well.
SHODAN · 2020-11-29 02:13
>>22614
lisp
(defun tuples (n domain)
(cond ((= 1 n)
(mapcar #'list domain))
((< 1 n)
(mapcan (lambda (list)
(mapcar (lambda (elt)
(cons elt list))
domain))
(tuples (1- n) domain)))))
BloodCat · 2020-11-29 02:41
>>22660
Nice approach, but the usage of names used in the standard language itself turn the code somekind confuse for me(beginner), like "list" and "elt" which are standard functions in :cl package.
Mitnick · 2020-11-29 15:44
>>22660
I made some corrections to my version from >>22641 namely changing the name of CONS-EACH to EVERY-CONS, replacing the IF with a UNLESS, adding the result-form as suggested in >>22647, and adding documentation. These are not what you've done. I also wrote a second implementation which allocated a matrix of two dimensions because I noticed that there was an awful lot of time being spent on GC, but this just quickly lead to heap exhaustion.
Would you mind explaining to me your justifications for your changes? I don't think proper tail calls are even mandated by the standard in Common Lisp unlike in Scheme.
>>22661
>Nice approach, but the usage of names used in the standard language itself turn the code somekind confuse for me(beginner), like "list" and "elt" which are standard functions in :cl package.
In Lisp-2s this is not uncommon. It's probably best to gain exposure to the use this naming style.
push · 2020-11-30 03:30
>>22683
It still completly based on what you did to my original implementation, I just tried to put your new changes and used FLET just for fun... I dont knew about FLET and LABELS until yesterday.
(defun tuples (n domain &aux (result (unless (zerop n) (mapcar #'list domain))))
(flet ((every-cons (heads tails)
(mapcan (lambda (tl)
(mapcar (lambda (hd)
(cons hd tl))
heads))
tails)))
(dotimes (i (1- n) result) (setq result (every-cons domain result)))))
Nobody special · 2020-11-30 03:42
>>22692
>new changes and used FLET just for fun...
Sorry for being rude; doing things just for fun is an excellent way to learn things. I haven't learned about FLET or LABELS yet, so I can't comment on your program (although I think I understand), but honestly keep up the good work
Bobby Newmark · 2020-11-30 03:55
>>22694
Iam just the guy which posted the first tuples implementation and pointed out the usage of dotimes return, You dont give me a single rude answer, I think the other guy which posted the recursive version dont get back til the moment.
I will keep sharing my naive implementations and learning from you all, I save all changes you guys teach me in a file called functions.lisp.
I agree you give a simekind rude answer to him, I think he was just trying to show another implementation, maybe for fun Idk, lets wait him appear again.
Tomohisa "Tom" Kanezaki · 2020-11-30 03:59
>>22699
Ah, okay.
>I will keep sharing my naive implementations and learning from you all, I save all changes you guys teach me in a file called functions.lisp.
You've got some fun problems, so I'll keep trying to post some alterations. I'm learning a lot myself, you'll recall I orginally was using LET instead of &aux parameters, and I didn't know about the result-form of DOTIMES. Also it's much easier to iterate on a solution than to come up with something novel.
Molly Millions · 2020-12-01 21:21
Is there any way I could get a REPL with auto indenting other than using SLIME? This really annoys me, but I'm weary of getting into emacs since it seems like a huge time investment.
↑ · 2020-12-02 00:09
>>22788
https://lispcookbook.github.io/cl-cookbook/editor-support.html
One of those other than Emacs might not be horrible, but I wouldn't hold my breath.
Jim Hilger · 2020-12-02 12:22
Is there something like format in reverse? i.e. I want to parse an arbitrary string into a set of variables according to a given pattern.
I understand that what I'm asking for is basically a full parser/compiler for strings of sufficient complexity, but it doesn't seem too outlandish for the basic case of a few numbers with labels.
Jens Hansen · 2020-12-02 15:20
>>21470
There are two books with LoL in the name.
vector · 2020-12-04 21:32
Does anyone know MIT scheme regex? I'm trying to use it for my advent of code solution and it's really awkward and unwieldy.
(define (try-match-exact pattern string)
(regsexp-match-string (compile-regsexp (append '(seq (line-start))
pattern
'((line-end))))
string))
(define (get-group matches group)
(cdr (find (lambda (x) (and (pair? x)
(eq? (car x) group)))
matches)))
(define (field-valid? field)
(let ((key (get-key field))
(val (get-val field)))
(cond ((eq? key 'hgt) (let ((matches (try-match-exact '((group num (* (char-in numeric)))
(group unit (* (char-in alphabetic))))
val)))
(if (not matches) #f
(let ((num (get-group matches 'num))
(unit (get-group matches 'unit)))
(cond ((string=? unit "cm")
(string-between? 150 193 num))
((string=? unit "in")
(string-between? 59 76 num))
(else #f))))))
((eq? key 'hcl) (try-match-exact '(#\# (** 6 (char-in numeric "abcdef")))
val))
((eq? key 'pid) (try-match-exact '((** 9 (char-in numeric)))
val)))))
Am I doing something wrong? Particularly, is there a better way to extract the values of capture groups from the match result? And is there a way to match "a-f" instead of "abcdef"?
Otto Normalverbraucher · 2020-12-06 06:26
In Common Lisp are there set operations (union, intersection) that work on sequences as opposed to just lists?
Anonymous · 2020-12-06 06:27
>>22940
Knuth · 2020-12-06 10:55
All of the Lisp programming I've been doing lately has been decidedly unlispy, in the sense Lisp is merely the implementation language, and a vehicle for ideas I'd ideally be implementing in a more rigid or simply different language once I fully understand and so know them. There's still time to do yet more interesting things with the year, though.
One idea I like is Lisp without S-expressions, meaning Lisp that's purely formed using the list structure, divorced from its textual representation. Going further, this could have interesting consequences for better manipulating Lisp programs. If there's no way to access a symbol's name in a program, there's no way the semantics of the program could be affected by changing it, sans any printing, if printing be available. This would enable changing a symbol's name mechanically, and much more easily than would currently be the case. Importantly, this would have no effect on symbol equality or anything else, for obvious reasons.
Since Lisp programs are text, changing a symbol name would usually be done by manipulating the program as text, and that's poor. I see the idea that weaker languages are useful for enabling complex manipulations thereof, but all that's truly necessary is understanding, which a stronger language such as Lisp can so easily support.
>>22815
Those would be LoL and LOL, so it's distinguishable.
>>22940
At a glance and from memory, it seems not. Checking section 17.3 The Sequences Dictionary of the Hyperspec reveals no such functions, although MERGE and REMOVE-IF or DELETE-IF may be suitable.
Trinity · 2020-12-06 16:35
>>22948
>[...] I'd ideally be implementing in a more rigid or simply different language once I fully understand and so know them. [...] I see the idea that weaker languages are useful for enabling complex manipulations thereof, but all that's truly necessary is understanding, which a stronger language such as Lisp can so easily support.
Is the ease of data abstraction then, rather than the environment, etc. the primary feature which motivates the use of Lisp in exploratory computing for you? I think this makes sense given that you've rejected part of the creed of Lisp, namely that systems should strive for universality (portable, standardized, generic, complete), due to your pursuit of (memory) efficiency. In the end I'm sure you've had your reasons for becoming a heretic. Regarding freeing Common Lisp from the text style, this would be nice to see.
Colmerauer · 2020-12-06 23:59
>>22961
>Is the ease of data abstraction then, rather than the environment, etc. the primary feature which motivates the use of Lisp in exploratory computing for you?
The primary features I enjoy in Lisp are the ease with which I can combine different types of data without forethought, yes, and also the metaprogramming. It's very convenient to distill something repetitive in a single macro. Complex macros are compilers, and compilers are a way for humans to distill knowledge and teach it to the machine.
>I think this makes sense given that you've rejected part of the creed of Lisp, namely that systems should strive for universality (portable, standardized, generic, complete), due to your pursuit of (memory) efficiency.
I don't quite know if I understand what's meant by this; rephrase it. As for efficiency of all kinds, the end products should have this, but the tools I work on which produce these end results need merely be efficient enough. It's far more important that the tool be correct, and to this end I've envisioned new designs which preclude certain classes of errors, at the expense of efficiency in some operations. I'm working on doubly-linked lists lately, so I may separate this work into a library.
Here's the core structure I'm currently using, although a library approach would do better with a class. I'll probably have a D package, so that DCBR here becomes D:CBR, which is about as good as it gets; this technically avoids unnecessary prefixing, while enabling it when mixing singly and doubly-linked list operations, and whatnot:
(defstruct (dcons :conc-name (:constructor dcons (dcbr dcar dcdr)) (:predicate dconsp))
"A doubly-linked list can be traversed backwards." (dcbr) (dcar) (dcdr))
This would be good work to finish before I truly begin other, unrelated work regarding doubly-linked lists. I think doubly-linked lists are nice, potentially much nicer than singly-linked lists, even.
>In the end I'm sure you've had your reasons for becoming a heretic. Regarding freeing Common Lisp from the text style, this would be nice to see.
It wouldn't be Common Lisp, just a Lisp. John McCarthy called Lisp a local optimum, and I'm not convinced Lisp in any recognizable form is really a long-lasting language as currently figured. What I know is the future of programming isn't, or shouldn't be, text; it should be dedicated tools which entirely eliminate classes of errors.
swap · 2020-12-07 18:04
>>22988
>It's very convenient to distill something repetitive in a single macro.
I've only personally used macros relatively naively for reifing some pattern inconvenient to express through other means (e.g. memoization), or to implement a special form. It's likely due to my inexperience writing languages that I hadn't fully considered the possibility of using macros for exploratory computation. This is something I'll attempt to keep in the back of my mind as I continue with my studies.
>I don't quite know if I understand what's meant by this; rephrase it.
I might simply be misunderstanding your development process; you might prefer to work out complete implementations before abstracting what they share in common. Regardless consider your MMC targeting Chip-8, this is clearly a specialized program with most procedures in the program being specific to the Chip-8 platform. My understanding was that this was done to avoid having the abstractions obscure or sully a more divine implementation. Of course there are many machines, but there are also many types of machines, and abstractions which can allow for individual machines to accept only part of even what is common of a type. So far as I can tell you seek to teach the machines their own language, so they can guide us, as we guide them; however, you do not teach them the divine language of the machines, but rather the parochial language of a machine in particular.
>As for efficiency of all kinds, the end products should have this, but the tools I work on which produce these end results need merely be efficient enough. It's far more important that the tool be correct, and to this end I've envisioned new designs which preclude certain classes of errors, at the expense of efficiency in some operations.
Of course, this trial does not concern heathenry which rejects the core tenants of Lisp, but merely a heretic who perhaps misinterprets. All in good fun as well I might add.
>It wouldn't be Common Lisp, just a Lisp. John McCarthy called Lisp a local optimum, and I'm not convinced Lisp in any recognizable form is really a long-lasting language as currently figured.
I won't bother you for further details, but I look forward to a read in the future.
>What I know is the future of programming isn't, or shouldn't be, text; it should be dedicated tools which entirely eliminate classes of errors.
Your writings have convinced me of this much.
Nanashi No Gombe · 2020-12-08 02:46
I forgot to note this thread is much faster than that which preceded it, which is nice.
>>23038
>I've only personally used macros relatively naively for reifing some pattern inconvenient to express through other means (e.g. memoization), or to implement a special form.
There's subjectivity to it. There was a point where I kept making a mistake, because I needed N forms added for every single addition of something, and I realized the error should be made impossible, because I should be using a macro to add such, so I did.
>It's likely due to my inexperience writing languages that I hadn't fully considered the possibility of using macros for exploratory computation. This is something I'll attempt to keep in the back of my mind as I continue with my studies.
I wouldn't strictly phrase it in terms of languages, nor even strictly exploration. If one sees the machine as a labour-saving instrument, then metaprogramming is perfectly natural, and it can take many forms, with macroes just being one. I wouldn't consider writing a specialized tool to be metaprogramming, but it can certainly be another form of labour saving. The point is to see drudgery and mistakes, and vanquish them.
>I might simply be misunderstanding your development process; you might prefer to work out complete implementations before abstracting what they share in common.
That depends. It may very well be the case I don't know what I'm building until after I finish it, in which case trying to abstract prematurely would be foolhardy.
>Regardless consider your MMC targeting Chip-8, this is clearly a specialized program with most procedures in the program being specific to the Chip-8 platform.
Yes, and I'm working on entirely rewriting it with a better internal representation for the second time. I like to make at least some progress on a meta-meta-machine code, and this new representation is promising for such.
>My understanding was that this was done to avoid having the abstractions obscure or sully a more divine implementation.
No, I simply had no way to remove and abstract them out, as I did with the three libraries I wrote in the process. My latest piece laments that I've no way to abstract a recollection system, undo and redo, into a general library. The best I can do is describe an interface, and implement it specially each time.
>Of course there are many machines, but there are also many types of machines, and abstractions which can allow for individual machines to accept only part of even what is common of a type.
I'm not certain I understand. In any case, each machine warrants special consideration, yes, but I'm also discovering some commonalities which I may later abstract into such a meta-meta-machine code, although I expect it may ever only reach the point where I've what's effectively a template generator I fill in.
>So far as I can tell you seek to teach the machines their own language, so they can guide us, as we guide them; however, you do not teach them the divine language of the machines, but rather the parochial language of a machine in particular.
No. My machine code work can be summarized concisely as simply removing drudgery from machine code programming. There's no need to require typing mnemonics into a text file and other such things, when it could instead be reduced to the smallest possible amount of human interaction. It's just an interface I saw in my mind when I was bored, that I've worked to bring to life.
>Of course, this trial does not concern heathenry which rejects the core tenants of Lisp, but merely a heretic who perhaps misinterprets. All in good fun as well I might add.
I may still be confused.
>I won't bother you for further details, but I look forward to a read in the future.
It may be a long wait.
>Your writings have convinced me of this much.
I'm glad.
Joe Bloggs · 2020-12-08 11:11
>>23048
>It may very well be the case I don't know what I'm building until after I finish it, in which case trying to abstract prematurely would be foolhardy. [...] I simply had no way to remove and abstract them out, as I did with the three libraries I wrote in the process.
Ah, well this makes sense. I probably should have just asked instead of accused.
>I wouldn't strictly phrase it in terms of languages, nor even strictly exploration. If one sees the machine as a labour-saving instrument, then metaprogramming is perfectly natural, and it can take many forms, with macroes just being one. I wouldn't consider writing a specialized tool to be metaprogramming, but it can certainly be another form of labour saving. The point is to see drudgery and mistakes, and vanquish them.
I see your point, and I can't think of a better description, but I disagree with the idea of the machine as merely a labor-saving instrument. This implies the machine has no influence on our thought, and that we could achieve the things we can acheive now without it. It may be true that in some ideal sense we can achieve the same thing as the machines without them, but it isn't true in a material sense, which is the only relevant sense. (despite the joking divination of various things mentioned earlier) The intimate connection between language (in the broad sense), thought, and the machines is something I need to consider further, but I'm sure it exists, just not in what form. (What are the implications of an instrument which is labor-savings with respect to thought?)
Regardless, you then think that Lisp offers superior instruments for labor-saving, and so is more desirable for exploration in the broad sense, so that you can gain a stronger understanding of your domain without fuss. You then seek to rewrite in order to take advantage of some other language's ability to gaurd against errors and exceptional cases. (I seem to recall you mentioning your desire to use Ada specifically due to its ability to withstand memory exhaustion) This seems reasonable to me.
>There was a point where I kept making a mistake, because I needed N forms added for every single addition of something, and I realized the error should be made impossible, because I should be using a macro to add such, so I did.
I see this idea lurking in the shadows every once in a while, but rarely explicitly stated. It's something along the lines of notation (or language whichever you prefer) is the way you build something rigid out of gas, gaining desirable properties in the transition for some domains. I'd like to begin a disciplined study of notation at some point, it seems ironic that so many in mathematics are dismissive of the utility of “mere notation”. Then again I suppose we're more interesting in proving properties than anything else these days.
>My machine code work can be summarized concisely as simply removing drudgery from machine code programming. There's no need to require typing mnemonics into a text file and other such things, when it could instead be reduced to the smallest possible amount of human interaction. It's just an interface I saw in my mind when I was bored, that I've worked to bring to life.
You mean to tell me that reducing human error through the restriction of inputs in a manner defined by the machine code was a mere side effect of attempting to reduce user input? You didn't intend for the questions the machine asks to guide our thoughts, or prevent mistakes but simply found the machine to be doing these things as part of a crusade against user input. I don't beleive you, or otherwise I think this is a rather poor description of your intent.
Iverson · 2020-12-09 17:27
>please some moderator delete the previous message Its giving error on delete here
I did a simple code after reading something about binary IO in pratical common lisp, the function w-file and r-file is just to quick test the read-ascii0 and write-ascii0.
My main question here is if we have some equivalent mapc which works on sequences, I did a the poor way and used map using nil as the return type.
(defun w-file (file-name val fn)
(with-open-file (out file-name
:direction :output
:element-type '(unsigned-byte 8)
:if-exists :supersede
:if-does-not-exist :create)
(funcall fn out val)))
(defun r-file (file-name fn)
(with-open-file (in file-name
:direction :input
:element-type '(unsigned-byte 8)
:if-does-not-exist :create)
(funcall fn in)))
(defun read-ascii0 (in)
(with-output-to-string (str)
(do ((c (read-byte in) (read-byte in)))
((= c 0))
(write-char (code-char c) str))))
(defun write-ascii0 (out str)
(map 'nil #'(lambda (c)
(write-byte (char-code c) out))
str)
(write-byte 0 out))
Six · 2020-12-10 14:10
>>22948
>>22940
I've run into a few other cases like this now. It frustrates me that CL doesn't fully commit to generic sequences. Even if arrays have a convenient reader syntax lists are still very much the only first-class structure. Having to change the way I write functions whenever I need random access makes things awkward.
Yamaoto Toshi · 2020-12-10 16:12
>>23121
>I've run into a few other cases like this now. It frustrates me that CL doesn't fully commit to generic sequences.
It's Common Lisp lain, the ceiling is very high, and committing to generic sequences is well within your reach. Alternatively you could use something like the ITERATE package, which has a LOOP like macro which is generic on sequences (including user defined sequences).
Leto Atreides I · 2020-12-10 18:23
>>23056
>I see your point, and I can't think of a better description, but I disagree with the idea of the machine as merely a labor-saving instrument.
I'm aware of this perspective, but wondered if my choice of phrasing would lead to something interesting.
>This implies the machine has no influence on our thought, and that we could achieve the things we can acheive now without it. It may be true that in some ideal sense we can achieve the same thing as the machines without them, but it isn't true in a material sense, which is the only relevant sense.
The best example in my mind of something computers do which isn't saving labour is video games.
>The intimate connection between language (in the broad sense), thought, and the machines is something I need to consider further, but I'm sure it exists, just not in what form. (What are the implications of an instrument which is labor-savings with respect to thought?)
The machines should be IA, Intelligence Amplification, by doing for the man what they can do perfectly and quickly, and deferring to him in all else. The difference between a current machine with current software and a piece of paper is that the paper won't forget what I tell it.
>Regardless, you then think that Lisp offers superior instruments for labor-saving, and so is more desirable for exploration in the broad sense, so that you can gain a stronger understanding of your domain without fuss.
It's that, the interactivity, and also that Lisp is that language I'm most familiar with. I think a lot about how inadequate Common Lisp is for interacting with the outside world. Writing something like SHA is nice, because it's self-contained; I debugged my PAD function by evaluating it from the file and testing it at the REPL, stepping through different cases, and making adjustments until it was correct. I later discovered a mistake I'd not noticed there, but that's irrelevant. A major improvement of mine MMC over the initial version was disconnecting the functions from the core of the system, so that the program accessed definitions floating in the ether, which made them reasonable to test at the REPL; I could've used SWANK for this while running it from the terminal, but I've never used SWANK, and don't want to learn, and this disconnect is inconvenient. Still, it was nice to be able to interactively debug a complex function that accessed the file system, seeing its current offset and everything else, without much effort needed on my part.
I criticize that current systems predominantly use UTF-8, due to an inability to reasonably use multiple character sets, but Common Lisp makes the same basic mistake, having one true character, compared to Ada, because I'm unable to program and trust character values are any particular encoding, which makes them useless for writing a standard program that must interact according to an outside convention; I could use :EXTERNAL-FORMAT in some cases, but that's not very useful in a standard sense.
All of this means I can never program in Lisp how I should be able to under these current systems but, if I'm to free myself from them, I'd rather pursue something more original, and perhaps embed Lisp in it akin to how Lisp has other languages embedded in it.
>You then seek to rewrite in order to take advantage of some other language's ability to gaurd against errors and exceptional cases. (I seem to recall you mentioning your desire to use Ada specifically due to its ability to withstand memory exhaustion) This seems reasonable to me.
Yes, although even Ada isn't necessarily safe from this. The Linux kernel purposefully makes reliability a fool's errand. Even SPARK Ada doesn't handle proving verified code will have enough temporary storage, such as a stack, and the solution is to use yet another program to analyze the code and determine the maximum ever potentially needed. Still, my lack of experience with Ada means I'm still yet to use it for much, and I may actually program most often in my machine code tool, second to Lisp.
>I'd like to begin a disciplined study of notation at some point, it seems ironic that so many in mathematics are dismissive of the utility of “mere notation”. Then again I suppose we're more interesting in proving properties than anything else these days.
Learn APL.
>You mean to tell me that reducing human error through the restriction of inputs in a manner defined by the machine code was a mere side effect of attempting to reduce user input?
Perhaps. Rather than painstakingly typing out a program, the human user initiates a brief conversation, which ends when the program has collected enough answers, but it could also be thought of as more than this. Relatedly, I hold the opinion that the machine should always allow human overriding, sans for those tasks the machine can truly achieve perfectly; a vehicle needs to accept commands from humans for many things, but controlling very intimate details of an engine hundreds of times per second isn't one of them.
>You didn't intend for the questions the machine asks to guide our thoughts, or prevent mistakes but simply found the machine to be doing these things as part of a crusade against user input.
I'm very careful to avoid names in my system, wherever possible. I don't want to name the instructions, and so represent them in their most distilled and unambiguous forms. Aspects of this design could certainly help guide others, but it can't guide me, because I entirely created it. It's merely what I want, to me. Preventing error is a natural consequence of a decent dedicated tool.
>I don't beleive you, or otherwise I think this is a rather poor description of your intent.
The concision elided nuance.
I'd like to have written a better response, but I've taken long enough.
Pulse · 2020-12-11 17:30
>>23134
>The machines should be IA, Intelligence Amplification, by doing for the man what they can do perfectly and quickly, and deferring to him in all else. The difference between a current machine with current software and a piece of paper is that the paper won't forget what I tell it.
I think IA (at least when used effectively) is an accurate description, but I will emphasize that there are certain things we can do now that we could not do before. For example approximating solutions to large linear systems required for differential equations often used in engineering, or inferring from massive data sets like those generated by particle accelerators.
It seems writing, speech, and computation all operate as IA by the reification of information. Where the human reifies their own knowledge this is done through the medium of language. I think it must be this language which effects thought, rather than the machines themselves, although it's a difficult decision. Consider the soroban, clearly the language of the machine effects thought allowing for far more rapid and accurate mental computation even when the machine has left, but without the machine to teach you it would have been dramatically more difficult to learn the language of the soroban.
>It's that, the interactivity, and also that Lisp is that language I'm most familiar with. I think a lot about how inadequate Common Lisp is for interacting with the outside world. A major improvement of mine MMC over the initial version was disconnecting the functions from the core of the system, so that the program accessed definitions floating in the ether, which made them reasonable to test at the REPL; I could've used SWANK for this while running it from the terminal, but I've never used SWANK, and don't want to learn, and this disconnect is inconvenient. Still, it was nice to be able to interactively debug a complex function that accessed the file system, seeing its current offset and everything else, without much effort needed on my part.
The interactive environment is very nice for testing and experimentation. The only reason I excluded its mention is because in the previous reply you seemed to imply that data-abstraction and macros were of primary use for exploratory computing. That being said I don't think the dynamic environment is sufficient for testing, and I'd like to see a system of property testing with the REPL being used for interactive debugging of failure cases generated by the test, and checking the base case during exploration. I haven't used SWANK either.
>I criticize that current systems predominantly use UTF-8, due to an inability to reasonably use multiple character sets, but Common Lisp makes the same basic mistake, having one true character, compared to Ada, because I'm unable to program and trust character values are any particular encoding, which makes them useless for writing a standard program that must interact according to an outside convention; I could use :EXTERNAL-FORMAT in some cases, but that's not very useful in a standard sense.
Yes, this seems like a major oversight of the standard, and I was truthfully surprised to see that this couldn't be done. Considering :EXTERNAL-FORMAT seems to not really be specified, it's not surprising that it isn't useful for these purposes. You do seem to have the option for 7-bit ASCII and derived encodings at least though.
>All of this means I can never program in Lisp how I should be able to under these current systems but, if I'm to free myself from them, I'd rather pursue something more original, and perhaps embed Lisp in it akin to how Lisp has other languages embedded in it.
This seems reasonable, also inline with the rest of your action concerning making your own foundations.
>Even SPARK Ada doesn't handle proving verified code will have enough temporary storage, such as a stack, and the solution is to use yet another program to analyze the code and determine the maximum ever potentially needed.
That's very unfortunate.
>Relatedly, I hold the opinion that the machine should always allow human overriding, sans for those tasks the machine can truly achieve perfectly.
I've been convinced of this point by the works of another.
>I'm very careful to avoid names in my system, wherever possible. I don't want to name the instructions, and so represent them in their most distilled and unambiguous forms. Aspects of this design could certainly help guide others, but it can't guide me, because I entirely created it. It's merely what I want, to me.
I suppose avoiding names is part of avoidance of premature abstractions mentioned earlier, and was one of the primary things I noticed to lead me to my earlier premature conclusions. I don't think having created a tool is sufficient to rule out learning from it, (think of proofs of mathematical properties which follow the definition of the object but which are unintuitive.) but I imagine in this case you are correct.
>I'd like to have written a better response, but I've taken long enough.
I do appreciate it and I think it'd be for the best that we end this conversation here. I've had my questions answered and have some ideas to further explore.
DEBUG-CONTENTS · 2020-12-11 18:15
>>23121
You either want Clojure or the Cloture implementation
Tank · 2020-12-12 00:27
>>23121
>Having to change the way I write functions whenever I need random access makes things awkward.
I don't see an issue.
; SLIME 2.24
CL-USER> (elt (vector 0 1 2 3 4) 3)
3
CL-USER> (elt (list 0 1 2 3 4) 3)
3
CL-USER> http://clhs.lisp.se/Body/f_elt.htm
Jim Hilger · 2020-12-12 08:39
In CL (CLOS)[0] I have a list l in the form '(symbol arg), how do I call the method named by symbol?
I tried ((car l) obj arg) but sbcl tells me this is an illegal function call. What ended up working was (apply (car l) (list obj arg)) but that seems like a weird solution and I'm missing something about how symbols are evaluated.
[0] I don't know if CLOS is relevant here, but I thought I'd mention it.
Batou · 2020-12-13 03:48
>>23194
(eval '(symbol arg))
St. IGNUcius · 2020-12-13 06:29
>>23194
As the >>23284 said eval will work fine in this case, but your apply version is not wrong or weird, but since you seems to know that the function named by symbol receive exactly two arguments you can use funcall instead.
Im assuming the number of parameter and format of the method in my example, I hope it give your some directions, but if its not what you want, the give me more about the context where your problem is happening. Here is the example:
(defclass some-class ()
((some-slot :initarg :some-slot
:accessor some-slot)))
(defmethod some-method ((obj some-class) arg)
(setf (some-slot obj) arg))
(defparameter l '(some-method some-arg))
(defparameter some-obj (make-instance 'some-class :some-slot 'initial-arg))
(format t "~&Before call: ~S~%" (some-slot some-obj))
;;; Example 1 (another option)
(funcall (car l) some-obj (cadr l))
;;; Example 2 (Like yours)
(apply (car l) (list some-obj (cadr l)))
;;; Example 3 (Like the >>23234)
(eval (list (car l) 'some-obj '(cadr l)))
Nameless · 2020-12-13 20:25
Does anyone archive these Lisp general threads? Old /g/ threads are archived so I was wondering.
(princ tripcode) -| · 2020-12-13 23:02
>>23293
I wasn't going to mention it myself, but yes. The only Lisp General here I've but an incomplete copy of is that from when Lainchan was wiped, as my WWW browser holding the complete copy had crashed. I was planning on simply keeping them for myself indefinitely, but I suppose I could host them on my website, were this wanted. Also know that reporting threads with a request for them to be placed into /archive/ is an option, although I don't do this because I don't want to be seen as favouring my threads in particular.
I suppose I'll note the work I'm looking to finish soon. My Common Lisp SHA is far too slow for practicality, so I'm going to reorganize the code to pursue an alternative design which only uses CLOS at the highest layer, along with some other tricks in pursuit of performance; it should be rather simple, once I actually bother to do it this month. I've continued mulling over the design of a doubly-linked list library, and quite like what I've thought of so far. I failed to have my latest tool in a state suitable for release yesterday, but expect to have it by Christmas at the latest. I started implementing CL:FORMAT months back, but have only finished a small part of the most interesting pieces, so I'll see if I bother researching and finishing that with this month. There's other Lisp work I want to pursue, but I'd rather stop myself from listing it, since I doubt I'd finish it in a reasonable span of time.
byte · 2020-12-14 11:16
I have this piece of code where I'm trying to generate a list of all permutations of a string but keep getting extra characters in the result, the code below is a minimal example to demonstrate the problem.
(defun string-permutations (string)
(if (zerop (length string))
'("")
(mapcar #'(lambda (s) (concatenate 'string (subseq string 0) s))
(string-permutations (subseq string 1)))))
This should return a list with a single string identical to the input, but instead it returns a larger string with repeating characters.
"ab' => "abb"
"abc" => "abcbcc"
Does anyone know why this is happening? I haven't been able to figure it out.
Spike Spiegel · 2020-12-14 20:32
>>23308
When you get to this point it's really useful to iterate through the base case in the REPL or mentally. As an example what do you expect to happen when you input "ab", this can be simplified to the following:
(concatenate 'string (subseq "ab" 0) "b")
; "abb" You can likely now see the issue considering you are concatenating the permutations after the first character onto the whole string, when what you want is only the first character of the string to be concatenated onto the remaining strings.
藤原純一 · 2020-12-14 20:47
>>23318
>when what you want is only the first character of the string to be concatenated onto the remaining strings.
Poor wording sorry. What you want is the remaining permutations to be concatenated onto the first character of the string.
Nell · 2020-12-14 23:54
>>23318
>>23319
ahaha, it hit me as soon as I saw your comment but I literally spent almost an hour staring at this yesterday.
Thanks for the help.
Vasya Pupkin · 2020-12-15 10:02
>>22948
Have you looked at Sussman's and Steele's constraint languages or Sussman's later work on propagators? The way I see it, good notation allows the programmer to build up truths. For instance in a conditional you know that the checked for condition is true inside its corresponding branch. Conditionals inside of conditionals can cover more and more cases until every possibility is handled correctly. My biggest problem with text is how inflexible it becomes. Making modifications to a large enough program eventually becomes a herculean task. I remember you talking about how you didn't want to build a conventional compiler or assembler. I imagine this is because the program is making assumptions for you about what information you want abstracted over. This can be helpful when there's a large amount of details but ends up inserting a bunch of strategies that get mixed with the designer's core ideas being expressed. Your solution to the problem where questions are asked and the environment resolves issues is very similar to constraint programming. The programmer gives only the information they think is important and the machine figures out the rest. If the machine has trouble establishing some truth, then the user can ask what the machine is missing until all the blanks are filled in with full detail. The program can then be queried for a list of justifications of some design choice and the user can zero in on exactly what problems are blocking a change of a truth in a specific direction. Once the thing is built, the user can then go in and change some truth which results in the program going through and getting rid of what comes out of that truth. The rest of the truths remain however and the designer can start building up to another fully detailed solution. Sussman uses it to build circuits although you seem to do something similar with filling in small details of machine code.
The Oracle · 2020-12-15 13:54
>>23341
FYI this is a different reader than before.
Technician · 2020-12-16 01:52
In Common Lisp, what is the best return value for a procedure which frequently does not apply to its inputs, and where it would be false to return the inputs as is? I know in some languages it's common to return a type which either contains some return value or a none value, would wrapping a type like this be desirable in Lisp as well, we obviously don't have the sum type exhaustion (whatever its called) to really make use of this, right? Signalling an error here seems more annoying to the user than anything.
What follows are further details on my exact procedure which can be skipped if you have a good general solution. I wrote a procedure to solve a matrix using the Gauss-Seidel algorithm. The algorithm converges to a value whenever ρ(I - (D - L)^{-1}A) ≤ 1. My procedure currently signals an error after running for some number of iterations but this isn't an uncommon event at all since the Gauss-Seidel algorithm doesn't converge for any matrix without the previously mentioned property.
swap · 2020-12-16 04:00
>>23375
I dont know if I really got what you want, but you can just return "no values" using (values), as in the screenshot example.
As you probably can imagine, if you try to capture the return value in this case it will be nil.
Tomohisa "Tom" Kanezaki · 2020-12-16 18:34
>>23375
>a none value
In Scheme you would use #!unspecific, I'm sure Common Lisp has something similar.
Haruyoshi · 2020-12-16 18:42
>>23381
or if you're combining the results, you would use an identity for that combinator (so if the combinator is + or -, you would return a 0, or if its * or / you would use a 1)
Agent Jones · 2020-12-16 18:57
There are other books with pratical projects in Common Lisp which is not Pratical Common Lisp?
Im acctually reading and trying to follow the examples of PCL, but at least for me the author have a very bad approach, he start building a thing, then I try to just implement it instead of just copying, but then the author just discard the idea for a "better way", he keeps doing this for most of pratical parts. I know that is a common thing to improve a previous implementation...
But when you are learning a thing and you just make things and throw the things in the trash its hard to keep motivated to continue, mainly due to reimplementing the things in a way that you cant reuse what you have done...
I dont know if the book will be this way in all pratical projets, im just in the second pratical project which is the binary parser macros (sometimes seems to be that the author made the things more complex without a real purpose, but maybe its just lack of experience of my part to read non trivial codes in CL.
I want to know from people whose had read this book, what they think about.
And any tips on pratical learning projects or guides are welcome too.
Aristóteles Amadópulus · 2020-12-16 19:25
>>23383
If you consider building 90s AI systems "practical", then "Paradigms of AI Programming" is what you want.
Kay · 2020-12-16 21:16
>>23383
I found Land of Lisp to be a good introduction to the language. The examples shown in the book aren't that practical, and some are CLISP-implementation specific, but I feel the author explains the language nicely.
Unidentified · 2020-12-16 22:42
>>23376
>I dont know if I really got what you want, but you can just return "no values" using (values), as in the screenshot example.
Is there a way for a caller to handle a no value return? Maybe the caller should just be expected to know if the procedure applies to their input and only call it when it's a viable solution, returning an error otherwise.
Leto Atreides I · 2020-12-16 22:58
>>23397
You already know before running the algorithm, if the function will not converge with the given inputs?
limited · 2020-12-17 01:46
>>23398
>You already know before running the algorithm, if the function will not converge with the given inputs?
It's not easy to compute but yes, for a matrix A it converges if and only if ρ(I - (D - L)^{-1}A) ≤ 1. Maybe the most relevant issues is that I don't know when this procedure would be used so attempting to decide on the return value is foolish endeavor in premature optimization. Here's the algorithm in case any of you are curious, also any commentary on it overall would also be helpful as I'm new to Common Lisp (I didn't post it earlier since it was for an assignment that was due yesterday at midnight).
(defun gauss-seidel
(matrix result &key approximation (tollerance 10e-13) (iterations 2000)
&aux (n (1- (array-dimension matrix 0)))
(xs (or (and approximation (copy-seq approximation))
(make-array (array-dimension matrix 0) :initial-element 0))))
(dotimes (k iterations (error "Maximum iterations exceeded."))
(loop :for i :from 0 :to n
:maximizing
(loop :for j :from 0 :to n
:unless (= j i) :summing (* (aref matrix i j) (aref xs j)) :into t0
:finally
(let* ((x (* (/ (aref matrix i i)) (- (aref result i) t0)))
(c (abs (- x (aref xs i)))))
(setf (aref xs i) x)
(return c)))
:into check
:finally
(when (< check tollerance)
(return-from gauss-seidel xs)))))
Dox · 2020-12-18 16:08
>>23402
One change I saw shortly after posting this was the following alteration: (/ (- (aref result i) t0) (aref matrix i i)) It's silly to multiply something by its reciprocal instead of just dividing...
Yamaoto Toshi · 2020-12-19 08:53
>>23341
>Have you looked at Sussman's and Steele's constraint languages or Sussman's later work on propagators?
No. I'll try to get around to reading the AI Memo at some point.
>The way I see it, good notation allows the programmer to build up truths.
That's one perspective, yes. I'm not currently certain if I'd describe my tool like this, however. There's a fundamental difference from uninteractive notation to an interactive tool.
>My biggest problem with text is how inflexible it becomes. Making modifications to a large enough program eventually becomes a herculean task.
That's why programs should remain small. Splitting a program into libraries makes a larger program manageable. APL is a good example of trying to keep programs small so they remain correct.
>I remember you talking about how you didn't want to build a conventional compiler or assembler. I imagine this is because the program is making assumptions for you about what information you want abstracted over.
It's because I fundamentally dislike programming and writing with streams of characters, requiring I remember irrelevant nonsense. I vehemently dislike the pseudo-operations of assembler languages, along with their stupid mnemonics. I know I can do better, and my way also reveals leagues more information to me, who can properly take advantage of it.
>This can be helpful when there's a large amount of details but ends up inserting a bunch of strategies that get mixed with the designer's core ideas being expressed.
I don't quite understand this well enough to be confident of its meaning.
>Your solution to the problem where questions are asked and the environment resolves issues is very similar to constraint programming. The programmer gives only the information they think is important and the machine figures out the rest. If the machine has trouble establishing some truth, then the user can ask what the machine is missing until all the blanks are filled in with full detail.
That's interesting; I've claimed many times that I've never seen an approach to machine code which resembles mine. In practice, the tool asks the same questions repeatedly, just with suggested defaults and other things. There's not much intelligence on the part of the machine. Names aren't recursive, so I wouldn't need to resolve cycles and whatnot. The design of the tool is what makes it powerful, not the tool itself.
>The program can then be queried for a list of justifications of some design choice and the user can zero in on exactly what problems are blocking a change of a truth in a specific direction.
My tool doesn't feature any such thing. The human operator is expected to know why everything was done, because he's the sole source of knowledge. I very specifically sought to avoid edge cases, and there's also no possibility in the system for it to ever be in an incorrect state; there's no such state as a partially-invalid instruction. When answering a question with an integer, named or not, the tool won't even allow an answer too large to be entered.
>Once the thing is built, the user can then go in and change some truth which results in the program going through and getting rid of what comes out of that truth.
There's no hierarchy here; it's flat.
>The rest of the truths remain however and the designer can start building up to another fully detailed solution.
Generally, if I want to improve a machine code program, I start over entirely, because my focus is optimization.
>Sussman uses it to build circuits although you seem to do something similar with filling in small details of machine code.
I'll need to read the paper to be certain; I'm not just filling in small details, but directing the entire process.
>>23383
I didn't much care for that book, but suppose this is in-part due to the many better Common Lisp books available. I learned the language by reading CLtL2.
>>23397
Generally, the MULTIPLE-VALUE functions are the only way to tell if no value was returned or not. Compare MULTIPLE-VALUE-LIST called on no return values to called on NIL.
Spooky · 2020-12-21 09:50
>>22812
CL-PPCRE with REGISTER-GROUPS-BIND
Sipho Nkosi · 2020-12-21 09:55
>>22812
CL-PPCRE with REGISTER-GROUPS-BIND
Drano · 2020-12-21 16:54
>>23383
This is not what you asked for, but Common Lisp Recipes is good if you already know Common Lisp the language. Rather than practical projects, you'll get introduced to some popular libraries and solutions for concurrency, network programming, regular expressions, web developing and GUIs. There are no big practical projects like in PCL, but the book is written so you can write all of the examples in sequence.
Zuse · 2020-12-22 20:06
I've released a library for manipulating doubly-linked lists:
gopher://verisimilitudes.net/12020-12-21
http://verisimilitudes.net/2020-12-21
This is the only other doubly-linked list library I'm aware of, which I didn't inspect until after writing what I've of mine so far:
https://github.com/krzysz00/dlist
I feel my chosen approach is better, using CLOS instead of STRUCTs, and I've a more Lispy approach to it. A doubly-linked list in my design has one extra field for its CONSes, which I've named CBR; not only does this scheme now use ABCD along with R, but it has a nice backwards mnemonic which may be used, although my library doesn't much enforce certain ways of working with them. I also like how my design makes good use of the multiple-value system.
My current plan is to continue expanding it with functions mimicking ever more singly-linked list functions, and also adding whatever I realize I need and which is suitable for placement in it, with my using it. I've nicely shortened the program I'm currently working on by using this library, removing specialized functions with library calls.
>>23510
I'm still preparing a response to this, but perhaps this discussion should be continued in the machine code thread: >>43
Consider taking that post, perhaps reformatting it a tad so it's not jilted when inserted there, and reposting it.
Crash Override · 2020-12-23 03:26
>>23518
Sure, I posted it as
>>23523
in the machine code thread. I lost the password for the post in this thread though so I asked in the irc for a mod to delete it. And I'm not sure what you mean by jilted exactly.
Cypher · 2020-12-23 18:11
>>23524
>I lost the password for the post in this thread though so I asked in the irc for a mod to delete it.
I may delete it later, so don't fret.
>And I'm not sure what you mean by jilted exactly.
I usually review my dictionary heavily when I write, but I didn't bother refamiliarizing myself with that word, which I now see I've used incorrectly; how embarrassing. I simply meant it may be jarring to insert a post continuing a discussion verbatim into one completely separate, and so adjusting it may have been good to do, but it's not particularly important.
Roger Pollack · 2020-12-23 23:06
How into Common Lisp or other dialects multithreading? Is there dialect that is especially good for multithreading?
Ender · 2020-12-24 22:09
I'm little bit confused about how one should manage dependency of common lisp project. If I don't want to use quicklisp for whatever reason (main reason being it downloads package over http without any kind of integrity check), could it be viable to just 'guix env' into my preferred version of common lisp environment?
nthcdr · 2020-12-26 07:13
>>23557
Common Lisp specs don't describe threads, so it's implementation-dependent feature. However, there are several libraries, that implement portable multithreading, Bordeaux-Threads is one of them.
https://www.cliki.net/thread
http://cl-cookbook.sourceforge.net/process.html
Leto Atreides I · 2020-12-27 14:12
>>23557
Clojure was built with concurrency in mind and excellent concurrency semantics. All data structures are immutable (thus thread-safe) by default. For shared state you have managed atomic reference types with different semantics: atom for CAS, volatile for volatile semantics, refs for transactions and agents for async semantics. On top of that you have core.async which gives you CSP semantics.
Moore · 2020-12-28 02:35
>>23466
> I learned the language by reading CLtL2
Someone told me that book was not good to learn Lisp since the language has changed so much since the book was released. Was that person right?
Batou · 2020-12-28 04:03
>>23595
The following page documents these changes: https://web.archive.org/web/20130807175341/http://bc.tech.coop/cltl2-ansi.htm
Dozer · 2021-01-17 14:08
I tried using StumpWM, but it's jarringly complex and changing the font is nightmarish. The fact that this is the only Common Lisp wm makes me want to write a Common Lisp wm that's modelled after dwm instead
John Titor · 2021-01-17 21:59
>>23557
If I were ever to try Erlang, it would be in the form of Lisp-Flavoured Erlang for just this.
>>23573
I just LOAD what I need. I've been intending to adopt a neat convention I'd created a ways back, storing files to LOAD complete Common Lisp units in a directory just past the home directory, since that's the only good directory for this Common Lisp can somewhat reliably access, but even I've not much adopted it, because it's easier for me to just call LOAD once.
To elaborate, the idea is to have a "common-lisp" directory just under USER-HOMEDIR-PATHNAME which would contain files that load the appropriate files from elsewhere. Importantly, this doesn't require LOADing anything such as ASDF, because it's stored in the file system. Dependencies would be handled by having the files contain recursive LOADs. I could elaborate further, but this is enough for the basic idea.
>>23595
I just read a list of changes as >>23600 described.
>>24007
>I tried using StumpWM, but it's jarringly complex and changing the font is nightmarish.
It's decent, and easy enough to customize compared to some others, but it could use a decent REPL. I don't have it connected to an Emacs instance in any way, so it's very inconvenient to run larger code fragments, which is just terrible. I ended up writing some changes to my .stumpwmrc and needing to temporarily change it to avoid undesired side effects, because LOADing that file was relatively easy to do. I've not often had StumpWM lock up on me, but it's possible, and it really shouldn't be. Now I'm just reminded of how I've wanted to pore through the source code and make a deeper change, at least one year ago.
>The fact that this is the only Common Lisp wm makes me want to write a Common Lisp wm that's modelled after dwm instead
Well, dwm is terrible primarily because of C, so that could actually be nice. Perhaps it could be done with CLX and then simply following the dwm source code. If the decision is made to carry on with that, discuss it here, and I may help. I'd prefer it use a copyleft license, were I to help.
aliased · 2021-01-18 00:55
>>24024
It's running well, but I'm unable to load quicklisp or any other packages into it. As you said, it could benefit from a decent REPL
If I find the time to write it, I'll try to make a st-like lisp terminal that doubles as a lisp REPL first since that's one thing that could help make hacking more convenient
I prefer the copyleft license too
Pulse · 2021-01-19 12:31
I'm interesting in writing a high-level interface for a simple stack-machine. Not a full compiler, but something where I can introduce logical operators and flow-control without keeping track of where I'm jumping.
Would Common Lisp be a good choice and how would you structure this sort of program? I've written a bit of Lisp before, but not this of thing.
Von Neumann · 2021-01-20 01:17
>>24041
If it's not speed intensive, I'd recommend trying Common Lisp. I'm just beginning to switch from C++ to CL and I can already feel a big difference in the SLOC, and there's a lot of stuff that'd have been very hard to implement with C++ that's trivial with CL.
Anonymous · 2021-01-20 06:30
>>24048
>>24041
CL can be VERY fast if you are running your code on SBCL and know how to optimize it. Of course it's not as fast as hand-optimized C, but still it's one of the fastest managed languages.
Ivan Horvat · 2021-01-31 21:27
Playing with doubly-linked lists more has shown me how the Lisp singly-linked list design hides a great many weaknesses with the weaknesses of singly-linked lists, so well that they're not even noticed. A number of functions for manipulating these aren't worth being given a name, so I'm forced to at times not name something and simply use chains of SETF, or name something that seems useful, but only in relatively limited contexts.
It's a learning experience, in any case.
>>24041
So how's this going? The obvious choice for representing the stack is as a list.
strike witches enjoyer · 2021-02-09 17:31
Help I can't enjoy algol-like syntax now, everything that's not scheme/lisp feels inferior
Koos van der Merwe · 2021-02-09 18:14
>>24395
Perfect. Proceed until you're convinced you'll never again respect a language with non-lispy syntax. Then learn something in the ML family.
Hiro Protagonist · 2021-02-09 19:23
>>24395
I used to be that way. After a few years of using Lisps the novelty of s-expressions wears off and you start seeing the merits of Algol-likes again.
The Plague · 2021-02-09 20:43
>>24395
It's worth knowing at least one such language. There's a league of difference between the C-likes and the Wirthian languages, such as Ada.
The utter uniformity is admirable, though. Consider looking into a language such as APL.
Iverson · 2021-02-24 13:37
I wanted to learn a dialect of Lisp. Is it better to start with Common Lisp or Scheme?
Jens Hansen · 2021-02-24 23:40
>>24594
I started with Common Lisp and later got into Scheme, mostly because the book, Land of Lisp, uses CL. It's a fun and interesting introduction to Lisp in general, in my opinion.
Now I enjoy Scheme because it's simpler and because Chicken Scheme allows type signatures and compiling to a binary.
Common Lisp is also said to be more practical because it has more features than Scheme in the standard.
Marly Krushkhova · 2021-02-25 00:10
>>24597
I thought about it and decided to learn Scheme, then go through the book, and then have a go at Common Lisp. By the way, how does Chicken compare to something like Gambit? I tried Guile, but it seems really clunky, and I couldn't figure out how to compile to a binary, so I'm looking for something that's easier to operate.
Cypher · 2021-02-25 00:20
>>24600
I haven't used Gambit, so I wouldn't know.
In Chicken, you have an interpreter (chicken-csi, csi or in Geiser if you use Emacs) and a compiler (chicken-csc or csc) which compiles to a binary.
Also, a lot of interpreters for Lisp systems have horrible line editing features if you run them outside of Emacs, so you should launch them with a utility program like rlwrap.
Colmerauer · 2021-02-25 00:44
>>24601
I took a look at both, and chicken seems to have more features. I will give it a try and see for myself. Thanks.
Jens Hansen · 2021-02-25 01:07
>>24604
>>24601
It seems fine so far, but there's two things bugging me - is there a way to disable the startup banner (in the csirc)? I tried to find something relevant in Modules page, but no luck. I know there's -q option, but geiser in emacs doesn't accept flags for launched interpreters I think. And I would prefer to put it into config file and forget about it.
Cypher · 2021-02-25 01:10
>>24605
Forgot to change two to one - I figured out the other while writing this post.
Cat Mother · 2021-02-25 02:05
>>24606
Ok, I figured out the second one too, but it's conflicting with the first one - it's either one or the other.
Technician · 2021-02-25 19:22
So, I was trying to wrap my head around pairs, improper and proper lists in Scheme. Can somebody say if I'm on the right track? From my understanding:
>pairs are two lisp objects bound together, where you can access the first one with (car) and the second with (cdr)
>pair elements can themselves contain other pairs (not sure if nested pairs is the proper term for this?)
>pair elements are separated with a dot .
>in case where cdr of a pair is a list, you omit the . opening brace and the corresponding closing brace
>a proper list is either an empty proper list, or a pair where it's cdr is a proper list
>improper list is a pair where it's cdr is not a proper list
>thus in a proper list consecutive cdr's eventually yield an empty list, and in improper list it won't
>all things considered lists are just pairs where cdr is a list
Is this correct?
Lady Jessica · 2021-02-25 20:16
>>24629
>in case where cdr of a pair is a list, you omit the . opening brace and the corresponding closing brace
Learn to use commas when listing things. I'd originally read this incorrectly. The following two are equivalent:
(1 2 3)
(1 . (2 . (3 . ())))
This seems a good understanding. Don't forget that circular lists, those which never terminate, are also improper.
Junichi Fujiwara · 2021-02-25 21:10
>>24630
>Learn to use commas when listing things.
I thought that ., would be confusing, maybe I should have just used dot, instead. Fair point.
Aristóteles Amadópulus · 2021-02-26 00:49
>>24629
What a mess.
(A B C D) is syntactic sugar for (cons A (cons B (cons C (cons D ())))), and (A B C . D) is syntactic sugar for (cons A (cons B (cons C D))). The dot is omitted when the last cdr is an NIL, the whole expression is called, conveniently, a list. It is present when the last cdr is anything but NIL.
Hong, Guil Dong · 2021-02-28 12:17
In scheme, when a variable is bound in the body of a lambda expression, for example by a let, is it free or not?
Nemissa · 2021-02-28 12:28
>>24712
To show what I mean, consider code like this:
(lambda (x)
(let ([y (cons x y)])
(x y z)))
z is obviously a free variable, but what about y?
Y.T · 2021-02-28 12:28
>>24713
And I obviously had to forget code tags
(lambda (x)
(let ([y (cons x y)])
(x y z)))
renames · 2021-02-28 14:40
>>24714
A let-expression is basically just an inverted-lambda. So (let ((x 0)) ...) is the same thing like ((lambda (x) ...) 0).
Wirth · 2021-02-28 18:13
>>24716
So in fact both y and z are free in the lambda, since they aren't listed in the lambda's parameter list?
hash table · 2021-03-11 15:16
Say I am thinking on building a web app with a fairly complex UI. Which one do you recommend: Clojure, Scheme or Common Lisp?
I am fairly proficient with Clojure, I have written a couple of projects for work. I like the Java interop, Clojure was my first lisp, and I chose it because interop. I do not know any Java. I also have the sense that if I were to eventually develop a desktop client, Being able to distribute it as a .jar would be a benefit.
But I am on the fence because of licensing. I would like the project to be GPL3, and I am not clear weather Clojure is compatible with that.
Soooo, CL and Scheme enter the equation. I have at most played around with Scheme, and I wrote a piece of CL code to educate my colleagues in the difference between a shell and a REPL. I am fairly comfortable with Elisp, so with two lisps under my belt, I do not think that working with a somewhat new one would be much of a hurdle.
Which one would you choose? Why? Which one would you definitely not choose? Any horror stories to share?
Thanks and much love.
Ein · 2021-03-11 18:04
>>24815
>I like the Java interop, [...] Being able to distribute it as a .jar would be a benefit. [...] CL and Scheme enter the equation.
You might then want to consider Kawa and Armed Bear Common Lisp (ABCL), both which target the JVM, and are sound implementations that have been sufficient to run industrial applications.
>But I am on the fence because of licensing. I would like the project to be GPL3, and I am not clear weather Clojure is compatible with that.
I would discourage you from letting licensing encouraging you to take a sub-optimal route to improve yourself. We have so little time. If you feel you would learn more using Clojure and generalization concepts (e.g. numerical analysis) rather than parochial language features, libraries, and syntax I would encourage you to do so. Especially since you could probably license under GPLv3 (or maybe AGPLv3) anyway just granting an exception to Clojure (also keep in mind this is only potentially necessary due to the dynamic nature of Lisps).
Joe Bloggs · 2021-03-11 19:14
>>24815
I recommend Common Lisp. The standard hasn't changed in decades, and it has real debugging facilities, unlike Clojure.
>Which one would you definitely not choose?
I'd avoid Clojure, which is a poor excuse of a Lisp created for attention, because Scheme and Common Lisp aren't cool enough anymore.
cdr · 2021-03-11 22:38
>>24822
>I'd avoid Clojure, which is a poor excuse of a Lisp created for attention, because Scheme and Common Lisp aren't cool enough anymore.
Anonymous · 2021-03-12 06:03
>>24815
If you're building a web app, a benefit of Clojure is you can use ClojureScript on the front end and Clojure in the back. You can use EDN as a transfer medium rather than more limited JSON or lists.
If you want to build UI in Clojure on the JVM your option is practically cljfx, which forces a certain mode and flow of work. If it's to your liking, good, if not, there nothing wrong with using another language.
If you're unsure regarding the licensing model, you should ask on the Clojurians slack, people there are nice and helpful.
The best reason to use Clojure besides its modern features and good defaults is the cruft it leaves out, mainly >>24822 and >>24833
cond · 2021-03-12 08:35
>>24820
>We have so little time. If you feel you would learn more using Clojure
>>24838
>you can use ClojureScript on the front end and Clojure in the back.
My main reason for Clojure is, I already know the language. I am considering quitting my job to do this because yolo. So not having to learn a new language is a plus. Furthermore, I have no experience with frontend/UI, and I am really scared about that, thus Clojurescript gives me a little confidence.
I have actually done some javascript for work, but I rather not go that route.
>>24822
>>24833
So, for frontend stuff, it seems CL has weblocks and there is this HOP.js that transpiles Scheme to js (something like that, I dont know), but documentation is iffy. What I am finding in general is CL documentation is iffy, so I think CL is getting less chances as of now. Racket seems to have decent documentation for its web stuff. But I am happy to get enlightened.
I actually like Scheme a lot in my limited use, and I dont know enough CL to have an opinion.
>>24838
>Clojure on the JVM your option is practically cljfx
But I can always use any Java library through interop. I the Clojure projects I have done, I pretty much used Clojure because I need some Java library, I told my boss that I cannot Java, so they let me use Clojure. Interop is its special kind of hell, especially if you know no Java, but I have gotten soykaf done.
Roger Pollack · 2021-03-13 12:36
>>24839
>especially if you know no Java
I came into Clojure knowing no Java. Have learned quite a bit by way of interop and reading Clojure's source.
Frontend, UI, and the browser are their own kind of hell. Godspeed
Vasya Pupkin · 2021-03-13 18:17
>>24822
This is really in poor taste. Elitism helps nobody in the Lisp community.
Unidentified · 2021-03-13 20:46
>>24839
>weblocks
Check out Parenscript.
>I have no experience with frontend/UI, and I am really scared about that
Some example apps here: learn-clojurescript.com
Church · 2021-03-13 22:51
>>24866
It's the truth. There were already several Lisp options for the JVM, and no reason for Clojure to strut on stage and pretend to be innovative.
Crash Override · 2021-03-14 05:32
>>24876
There's no need to pretend to be innovative when you are innovative.
Cutter · 2021-03-14 10:17
>>24866
90% of lisp culture is elitism. Rightfully.
Vasya Pupkin · 2021-03-15 08:45
>>24862
> Godspeed
Thanks, I need all the encouragement I can get.
>>24873
Thanks for the info.
>>24866
>>24876
>>24881
>>24885
I do not see how any of this is constructive to any conversation. Some people like Clojure, some dont. Same goes with CL and Scheme. And most non-lispers dislike anything that is related to lisp.
I am only trying to gauge what is the best lisp for my particular project. I love all of them.
Lady Jessica · 2021-03-15 15:55
I tend to think that Scheme, CL, Clojure, New- and PicoLisp are all lisps or lisp family languages in the same sense as C, C++, Java, Pascal and Perl are all algol family languages. No less and no more.
What do you think?
Elliot Alderson · 2021-03-15 19:29
>>24889
Consider me properly chastised. I let myself get carried away.
>>24895
I agree, we should all be a big happy family. If only we could get along, yes?
Iverson · 2021-03-15 20:20
>>24899
Can you imagine Perl programmer and Java programmer getting along? It's beyond my imagination.
Lady 3Jane.. · 2021-03-15 20:54
>>24902
I meant Lisp hackers getting along with each other, instead of acting like a bunch of cats
Lady Jessica · 2021-03-15 23:08
>>24904
What I meant is that getting along for Clojure programmer and CL programmer is as hard as getting along for Java programmer and Perl programmer.
Maybe it's enough to just understand that CL and Clojure is very different languages and stop clashing. Not getting along, but at least agree to disagree.
Koos van der Merwe · 2021-03-16 10:24
>>24908
>>24902
>>24904
But this is what I don't understand, they are different tools, and it is nice to have different tools in your toolbox. I just don't get the hate. Even some algols have their use cases...
Example:
I work at a Python shop. I inherited a piece of java code. I have not used Java, ever. So I did what I had to do in Clojure. I am not even a SE or programmer, but a statistician. Everyone else in my team are SE / programmers with Java education. The amount of lisp hate among my peers made them spend their free time writing a Java version of my code, which ended up being an unusable piece of garbage, because I solved a thing with a little macro, and they wrote about 200 lines of code forgetting to include half the required cases. Still I was called a "wanking academic" doing things that have no place in business. like what? working software?.
Clojure was definitely better suited for that thing, but honestly: Why so much hate? Why go out of your own way so the company does not have a line of lisp code serving to customers? It was a waste of everyone's time.
Two years later and I believe that piece of Clojure to be the longest serving piece of code at work...
Cypher · 2021-03-22 15:05
>>24915
Sounds like you are working with some very bottom-tier programmers at your job. My condolences, fellow Lispers, but on the bright side, it's more or less the same at my workplace (and even though I'm a developer, I still couldn't convince my peers to use any Lisp dialects).
And yeah, us Lisp communities (Common Lisp, Scheme, Clojure, etc.) need to band together because Jesus H Christ the irrational hatred and FUD from other programming language communities are unreal and we really need to unit to stand against them.
Lunch · 2021-03-23 16:00
>>25023
We need to push for lispy new things whenever possible.
If you work in Python, do things in Hy.
If you're on Java, bring in Clojure.
If you're on C bring in SBCL, on C++ CLASP
Do all your personal scripting, automation, etc in any lisp of your choosing. Share it with anyone who needs it.
Elliot Alderson · 2021-03-29 05:26
>>24915
> doing things that have no place in business.
> like what? working software?.
Unironically yes. Software Engineering was solved in the 60s. To this day the only reason why new methodologies keep getting created is because higher-ups demand it (and so do mediocre programmers).
dictionary · 2021-04-03 00:15
Where do my fellow Schemers find documentation? CL has the Hyperspec, do you just read the RNRS standards? Chicken Scheme has its own set of docs with a wonderful tool for searching through them (chickadee).
Hitomi · 2021-04-03 17:32
>>25224
I'm only a small-time Schemer, but I refer to my implementation's docs. I deal mostly with Gauche, which has absolutely gorgeous documentation, and Guile, which also has a very comprehensive manual.
Basically, after being faced with the variety and diversity of implementations, my approach to Scheme has been to write for this or that implementation rather than for Scheme in the abstract, so this is the most natural way for me.
cond · 2021-04-05 22:01
>>25047
I like this, it's like Lisp praxis.
I'll start with converting all my shell scripts to a Lisp. I don't want to argue about implementations, but would Guile be suitable for this kind of thing?
Neo · 2021-04-05 22:11
>>25260
Use Elisp.
https://www.emacswiki.org/emacs/EmacsScripts
The Oracle · 2021-04-06 12:23
>>25260
As the resident heretic in this thread who made the proposal you're responding to, use babashka
https://github.com/babashka/babashka
array · 2021-04-06 17:50
>>25260
Guile might be good, but I think that Gausch could be better. Reading through the manual, it seems to be a better Perl/Shell/AWK replacement, and it implements more SRFIs than Guile, promising more portability.
Anonymous · 2021-04-09 23:06
>>25260
You could try changing the interpreter to https://github.com/SquircleSpace/shcl and replace the script contents bit by bit.
Nameless · 2021-04-10 00:09
How did you get into lisp? I got into C programming through fixing problems on my system, mostly C programs, and the language is a part of my daily life in that way. Everyone talks about their C programs and so on, it's just impossible to ignore. At least where I am right now, lisp has to be actively searched for, though I know a couple of people who use it.
While lisp seems interesting and I mess around with it occasionally, it never really amounts to much. Maybe a repl-session lasting a few minutes just running some stdlib functions. How should I go about getting more into it until I can develop a self-sustaining proficiency in the language, since I don't really have the safety net of everyone else's programs that I'm already using being written in it?
I'm 90% sure that I do actually want to do this, what little I do see is fairly captivating. The idea of a recursive anonymous function, or even just the combination of functional and imperative modes (I've also messed around with haskell), is really appealing, not to mention the extensibility of the whole thing with macros.
Nell · 2021-04-10 01:02
>>25334
I got into Scheme from a similar position to you by using GNU Guile. It's made to extend and script C programs so you can call specially constructed C functions from Scheme.
The Guile reference is very good documentation and takes you through the process of taking an existing C program and basically stapling a Scheme repl to it. Thanks to SXML I will probably never build a parser in C again and thanks to mcron I'm putting more tasks on timers than before.
Cereal Killer · 2021-04-15 21:58
>>25334
Here's some good resources to learn more about lisp
- https://anticrisis.github.io/2017/09/04/how-i-got-started-with-common-lisp-2017.html
- https://www.grammarly.com/blog/engineering/running-lisp-in-production/
I think for what you're trying to do you may want to look into ECL, Guile, or Chicken Scheme as they are used in tandem with C. I've used both Chicken and Common Lisp to create small applications to automate things on my machine as well as things at work. It depends on what interests you and also if you enjoy what lisp has to offer.
Agent Jones · 2021-04-19 13:41
>>21193
>Which dialect do you prefer?
Chicken scheme
>Do you use Emacs or a different lisp-based editor?
Vim with slimv
>What was your first experience with lisp?
sicp
>What have you made in lisp?
Simple programs to solve challenge and one small game
>What do you like about Lisp?
()
>How long have you been programming in Lisp?
2years
>What are your favorite Lisp resources? Please share, preferably links!
https://wiki.call-cc.org/man/5/The%20User%27s%20Manual
Watching others project code
>Is Lisp your main programming language or not? Regardless, what do you primarily use it for?
No but I want to master it so recently I try to do all I can with it
>What would you like to see in the Lisp general?
Lisp code, tips and tricks, projects that use lisp
>Do you use more than one dialect? What are they and which do you prefer?
Sometimes I use common lisp
>What do you consider the criteria for what constitutes a Lisp to be?
(), macros
>What is your favorite function in your chosen dialect(s)?
lambda
Zhora · 2021-05-21 08:06
If you were to make a lisp interpreter in C how would you go about doing so? And any resources you would recommend looking at? I have found this one to been very good overall guide for reference for building: https://www.lwh.jp/lisp/.
nthcdr · 2021-05-21 09:35
>>25905
I can't recommend any papers about implementing a minimal lisp interpreter, but you may look at the source of Kilo Lisp for reference.
http://t3x.org/klisp/index.html
FILLER · 2021-05-21 20:27
>>25905
The book "Structure and Interpretation of Computer Programs: Second Edition" has very well written introductory guides to making Scheme interpreters/evaluators; I'd recommend reading it.
roll · 2021-05-21 22:31
>>25905
http://norvig.com/lispy.html
https://bernsteinbear.com/blog/lisp/00_fundamentals/
http://peter.michaux.ca/articles/scheme-from-scratch-introduction
http://www.buildyourownlisp.com/contents
The first two use different langs, but you sgould be able to translate. If you'd like a book, there's Lisp In Small Pieces.
DEBUG-CONTENTS · 2021-05-28 23:01
I love using the Scheme Lisp variant, but I have yet to find any good 3D graphical libraries for it (say OpenGL). Do any exist that I have missed? I would really like to make 3D applications with Scheme.
Guthrie · 2021-06-03 19:26
What is your favorite Common Lisp library for dealing with postgres?
I did limited research and postmodern seems ok, but I am not sure I like DSLs since I have always written SQL into sql files and then read file and executed.
Is it worth learning a DSL like postmodern? Am I completely wrong in my assumptions of how postmodern works? Should I check a different library?
Jim Hilger · 2021-06-04 17:36
>>25905
You would start by splitting the input text into tokens, then you would parse the tokens into a tree data structure, and then you would walk the tree while updating some global data. The first two steps involve mountains of theory, but Lisp syntax is simple enough you can just wing it and end up okay.
(define items (list 1 2 3))
=> ["(", "define", "items", "(", "1", "2", "3", ")", ")"]
=> ["define", "items", ["list", "1", "2", "3"]] The last step is just walking the tree you parsed while updating an associative array (dictionary) of bindings. A mini-language with 'define', 'set!', 'if', 'progn'/'begin', '+', '-', '=', '*', and '/' is enough to keep you busy.
Someone already posted Norvig: http://norvig.com/lispy.html
⍕ · 2021-06-06 14:04
What kind of environments do y'all use for programming in Lisp? I've been using Emacs, slime-mode for Common Lisp and Geiser for schemes. I wonder what useful packages lainons would recommend, I've used just smartparens.
hash table · 2021-06-06 14:58
>>26122
Lispy
https://github.com/abo-abo/lispy#demos
Slime
https://lispcookbook.github.io/cl-cookbook/emacs-ide.html
https://bnmcgn.github.io/lisp-guide/lisp-exploration.html
What else do you need?
Linda Lee · 2021-06-07 15:46
>>26082
Just to update the situation and in case someone is in a similar situation. I have been working with postmodern since I asked the question and I quite like it. The DSL is a no brainer. There is almost nothing to learn, just translate sql to lisp in the most obvious way and you will get things working 90% of the time. The documentation is quite good.
Nguoi La · 2021-06-16 08:26
This is a simple function I've written, as a desirable component of future work I've planned. It was easy to write, implementing the ⍋ function of APL. It's AGPLv3, but for licensing purposes the source is here:
http://verisimilitudes.net/2021-05-31
(defun grade (sort vector &optional stable-sort &key ((:key every) 'identity))
"This function returns a vector of indices corresponding to the sorted order of the input vector."
(let ((array (make-array #0=(length vector) :element-type `(integer 0 ,(max 0 (1- #0#)))
:initial-contents (loop :for count :from 0 :repeat #0# :collect count))))
;Through the compiler, this function goes. Would :INITIAL-CONTENTS be best? Well nobody knows!
;(dotimes (count #0#) (setf (aref array count) count))
(funcall (if stable-sort 'stable-sort 'sort)
array sort :key (lambda (aref) (funcall every (aref vector aref)))))) The purpose of this primitive is to not only sort data, but permit transforming other data based on the new ordering. Amusingly, Lisp provides an easy way to avoid using this. I believe using linking structure to defer giving numerical indices until all transformations are finished may be the superior approach. Still, this was trivial to write, taking only twenty minutes or so in total.
I've posted an Ada version here: >>26271
Von Neumann · 2021-07-04 06:29
I need some advice Alice. I've gotten through the first 100 pages of SICP but I'm a math fool and the pure math examples are not making sense to me. I have a hard time figuring out what the math example is, trying to figure out how the code maps to the math is fuarrking with me. What other book should I use. I have Lets over Lambda, the Guile manual, and the Little Schemer. The Guile manual has been ok so far but I havn't tried LoL and little schemer yet. Any advice for how I should continue?
Lukasiewicz · 2021-07-04 11:12
>>26526
Continue with The Little Schemer
Cereal Killer · 2021-07-06 14:07
>>26526
Your solution when something is hard is to give up? Figure the math out, read about it, ask online. You are sabotaging your learning in the long term if you avoid difficult subjects.
sizeof · 2021-07-06 16:53
>>26570
to be fair, theyve already done at least 33% of what youve suggested
FILLER · 2021-07-06 17:33
>>26526
Some of the mathematics within SICP is much higher than high school level, which is what most people know; the target demographic for SICP is MIT students, remember. Personally, I tried my best to understand the mathematical exercises I didn't understand and then moved on. Most of the very difficult mathematical exercises aren't necessary to read the book in my opinion, and I was fine when I skipped some of them, this also goes with quite a few other exercises which aren't necessary.
Just another Random Lainon · 2021-07-06 19:31
>>26572
My suggestion is to not give up because something is hard, giving up (which he is doing) means 0% of my suggestion has been done.
Dozer · 2021-07-07 01:20
>>26573
What maths are you talking about? I don't remember it being much more complicated than differentiation and things like Newton's Method.
Milner · 2021-07-07 08:00
>>26589
There is some discussion about complex numbers that a highschooler might not know (or at least I didn't know the rules when I read it).
x<->y · 2021-07-07 09:01
>>26593
You don't need to know anything about complex numbers to do the exercise though. They explain everything you need to know (two representations, how to convert between the two).
Cutter · 2021-07-07 18:14
>>26589
I think I remember chapter 1 had at least 1 exercise proving algorithmic complexity of a divide and conquer algorithm, which was too much for me.
⍕ · 2021-07-07 18:58
With programming requiring some of the same skills that mathematics sdoes, I wonder if it's a good sign that programmers keep complaining about having math in their books.
I'm not claiming to be good at math, but I wouldn't dodge the math problems, quite the opposite.
John Doe · 2021-07-08 06:52
>>26607
Not all programming require math past high school. Anything math related I just use libraries for. Call me a fool but thats how I do it, and I do it all the time.
Y.T · 2021-07-08 14:22
>>26614
Shouldn't you be in the javascript thread?
Unnamed · 2021-07-09 16:28
>>26618
What kind of nonsensical response is that?
While other lainon shows they probably also don't care about computer science in general, that doesn't mean they can't use Lisp to build programs anyway.
Why recommend them worse tooling?
FILLER · 2021-07-09 22:40
>>26641
Having powerful tools is no substitute for problem solving and general mathematical literacy.
This kind of attitude that dismisses math as a nuisance and relies on libraries to solve your problems is the kind of attitude championed by webdevs and others who tend to stack third party code and busy their (and other's) processors with hundreds of function calls and poorly engineered code.
Cowboy · 2021-07-09 22:59
Found this material, and was curious how does one make a lisp compiler in lisp from a lisp interpreter that you built prior?
It is mentioned here: http://peter.michaux.ca/articles/scheme-from-scratch-introduction
In the area "Compiling Scheme A Scheme to i386 Assembly compiler written in Scheme. First executed with Bootstrap Scheme but later self compiling."
However the original author didn't write about past the bootstrapped scheme interpreter part in the blog posts. Wondering if it is possible.
Unsigned · 2021-07-10 19:42
>>26652
Just use the nanopass compiler in your interpreted scheme and voila
Cowboy · 2021-07-12 19:23
>>26651
Having powerful tools is no substitute for problem solving and general electrical literacy.
An attitude that dismisses electrical and computer engineering as a nuisance and relies on premade hardware to solve problems is the kind of attitude championed by software "engineers" and others who stack third party hardware and busy their (and other's) equipment with millions of wasted cycles and poorly engineered solutions.
Lord Nikon · 2021-07-12 21:05
Has anyone used uLisp or a similar dialect which is designed for microcontrollers? I've got some arduinos gathering dust and this caught my interest:
http://www.ulisp.com/
Void · 2021-07-16 19:19
>>21193
might have already been asked but why are none of the members of the lisp family used frequently or much at all in production? What does lisp lack that Python, C, and even Lua have?
Morpheus · 2021-07-16 20:25
>>26775
There was a talk about this in ClojureTre, you can watch it here https://www.youtube.com/watch?v=QyJZzq0v7Z4
The TLDR is mostly inertia
Specific lisps have problems endemic to them, but there are things which could make them succeed, like a "killer app". An example of this today could be Roam / logseq for Clojure.
I wonder if the standards actually had a detrimental effect. Take Python, for example. There is only one canonical Python. There aren't competing implementations. There are other implementations which offer different things but ymmv and use them only if you know what you're doing and have specific constraints. But when you have standards, everyone can come up with their own implementation and fragment the ecosystem, as they're never truly 100% compatible.
quote · 2021-07-28 01:53
What would you use if you wanted to write a gui app in a lisp?
Ishikura "Tatsu" Tatsuhiko · 2021-07-28 03:10
>>26894
I'd use clojure with cljfx
Armitage · 2021-07-29 21:03
>>26894
I've been doing a bit of learning mcclim. It seems like a pretty controversial toolkit because it's very different from other gui toolkits, but I've never done any gui programming before and like that it's written entirely in common lisp and (theoretically at least) has a totally pluggable backend architecture. So you can just program a gui with a high level of abstraction and not have to worry about it working on different OSes.
Lack of backends and CLX are issues people have with it, but it's a very actively developed project and from a pure coolness factor and being tightly integrated with lisp it's worth learning IMO
Hong, Guil Dong · 2021-07-29 22:17
>>26894
Were it an option, I'd write a "TUI" using the ACUTE-TERMINAL-CONTROL library I wrote; were it not, I'd use Emacs communicating with the Common Lisp system. Anything else would be too hard or too wasteful.
Yuki Nagato · 2021-08-04 21:08
Are there any good ways to write GUIs outside of OOP or should I just embrace CLOS?
Roger Pollack · 2021-08-04 23:20
Rich Hickey is a bigger piece of work than I thought. I finished reading this recently:
https://github.com/matthiasn/talk-transcripts/blob/master/Hickey_Rich/EffectivePrograms.md
He admits Clojure exists because of foolish managers who won't permit Common Lisp. He describes situated programs, ignoring CLOS, and more importantly ignoring how any working program is composed of simple parts, simple mechanisms, which work like gears; living beings are also like this.
Whatever edn is, he certainly thinks it's special over what other Lisps have. See how he retreats into weasel words, with these vague programs:
>So finally, Information vs Logic. The bottom line is, "where are we going in programming?", right? The fact is, we actually don't know how to drive a car. We can't explain how to drive a car. We can't explain how to play Go. We can't...and then, therefore we can't apply traditional logic to encoding that and make a program that successfully does it. We just can't do it. We're approaching problems in programming now that we don't know how to do. We don't know how to explain how to do. Like, we know how to drive a car, but we don't know how to explain how to drive a car. And so we're moving to these information-trained brains, right? Deep learning and machine learning, statistical models and things like that. You use information to drive a model that's full of imprecision and speculation but that is still effective because of the amount of data that was used to train it at making decent decisions, even though it also couldn't explain necessarily how it works. These programs though are going to need arms and legs and eyes, right? When you train a big deep learning network, does it get its own data? Does it do its own ETL? No. Right? It doesn't do any of that. When it's made a decision about what to do, how's it going to do it? Well, when we get to Skynet, it won't be our problem anymore.
These programs are nothing but ruin when they touch anything important, not that he sees the issue.
>Real-world safety is going to come from experience, not proof
It's an injustice that the idiots who believe this aren't usually those harmed by it.
Lady 3Jane.. · 2021-08-05 00:57
>>26962
Don't be afraid of CLOS, anon. OOP can be great if done correctly and common lisp does it well. That being said you should be able to accomplish basically anything with common lisp; I know that there's the EQL5 toolkit that uses ECL to embed Qt5. since Qt5 uses its own language (QML) to declare widgets and such, it would probably be possible to fairly easily make a transpiler from lisp to QML.
Disclaimer: I don't know that much about Qt5/EQL5. I prefer to stick with CLIM.
Here's a link on GUI toolkits for lisp: https://lispcookbook.github.io/cl-cookbook/gui.html
>>26963
I thought it was common knowledge that Clojure exists because the only way to sell lisp to companies is by having it be on an established platform like the JVM. Ironically, Paul Graham wrote about this phenomenon a few years before Clojure was developed (http://www.paulgraham.com/avg.html) and concluded that if you want to really innovate, you need to take risks in order to give yourself an edge and that means using whatever technology is the best tool for the job rather than whatever happens to be the most well-supported or adopted. Though Paul Graham also happens to be ignorant/dismissive of CLOS, funnily enough.
Zero Cool · 2021-08-05 01:57
>>26964
The annoying part of this is that ABCL is perfectly usable and would've benefited from all those programmer hours in implementing the few parts of Java interop it was missing.
stack · 2021-08-05 02:07
>>26966
I've never used ABCL myself because I haven't had a need for Java interop, but yeah, I've thought the same thing. It's really frustrating but the sad truth is that the tech industry is a sewer and the adoption of technologies is largely based on trends, so Clojure had to be made solely for it to be a shiny new toy to dangle in front of the managers responsible for adopting technologies at companies.
I didn't realize this, but ABCL has also been around practically as long as Clojure. What a fuarrrking shame. At least it's still pretty actively developed.
The main "benefit" to Clojure from my point of view is Clojurescript; it's a really nice way of doing webdev if you must do something so unpleasant. I really wish common lisp had something comparable to that. Parenscript is alright but it doesn't feel as seamless to work with by any means, though maybe I just don't really know how to use it very well yet. I know there's also Valtan, JSCL, and JACL being worked on, so hopefully CL will get something like Clojurescript soon
t · 2021-08-05 07:03
>>26963
You totally missed the point
>He admits Clojure exists because of foolish managers who won't permit Common Lisp
That was the impetus, but he still thinks the result is better than CL
>He describes situated programs, ignoring CLOS
They have nothing to do with one another
>ignoring how any working program is composed of simple parts, simple mechanisms, which work like gears; living beings are also like this.
Go watch Language Of The System before writing such silliness
>It's an injustice that the idiots who believe this aren't usually those harmed by it.
Every bug in a Haskell system made it past the type checker.
I get the impression you're not very familiar with Clojure
>>26966
Have you considered Clojure might be better? Go to the mailing lists and see why he didn't go with ABCL
() · 2021-08-07 21:25
Any tips for getting good at Lisp/Scheme quickly?
Is SICP still worth reading or are there better books today?
I like learning by doing practical and useful examples the most.
I want to be able to make more or less efficient code and know Common Lisp and Guile fluently.
Drano · 2021-08-07 21:50
>>27001
if you know how to program just read the docs, if you don't read sicp
Jean Dupont · 2021-08-07 22:10
>>27002
I can hack garbage together in a somehow clean way but that's it.
I understand the basic concepts of programming but I haven't got any proper algorithmics or software engineering education.
John Doe · 2021-08-07 22:39
>>27001
SICP isn't meant to teach you lisp, it's a textbook for learning computer science. it's definitely worth reading but not for that reason.
the best way to learn (common) lisp is to read Practical Common Lisp (https://gigamonkeys.com/book/) and go through the whole thing. Another good introductory book for lisp is Common Lisp: A Gentle Introduction to Symbolic Computation (check libgen for a pdf). the former would be good for you because the whole book is a lot of practical exercises where you're writing code rather than learning a bunch of theory.
the Common Lisp Cookbook (https://lispcookbook.github.io/cl-cookbook/) is a great resource for when you need to look up how to do something.
I also recommend reading this blog post before doing anything just to get a high level overview of common lisp and how you should go about learning it: https://stevelosh.com/blog/2018/08/a-road-to-common-lisp/
synchronized · 2021-08-08 03:45
>>27001
Lisp was designed to be simple as far as I can tell, so learning it quickly isn't much of a challenge; I recommend a read of "The Little Schemer".
Switch · 2021-08-08 06:07
>>27001
there's a new SICP in 2022 using javascript on MIT book
take Sussman's other new book https://mitpress.mit.edu/books/software-design-flexibility which is on library genesis for free
You don't need SICP to complete it, the appendix is good enough assuming you have a programming background of any kind.
Hiro Protagonist · 2021-08-08 08:00
>>27008
Flexibility is great, but it's not an introductory book. It's for experienced engineers in general.
To get into stuff quickly, The Little Schemer is a good path. Don't know if there's a book for building practical stuff in Scheme, that's more CL and Clojure's forte.
DEBUG-CONTENTS · 2021-08-08 14:38
Is Racket as capable as Common Lisp for normal applications, or is it only usable for academic research?
The fact that Racket doesn't have a defined standard concerns me a bit if I have to be honest.
Nobody special · 2021-08-08 15:06
>>27013
Python, Ruby (Except for 1.8), PHP, and Go don't have standards, but people still use them.
Dozer · 2021-08-08 17:15
>>27004
>>27006
>>27008
>>27009
Thanks for the tips.
Anonymous · 2021-08-08 22:30
>>27013
>>27014
the main problem with a language lacking a standard is that you're going to have to deal with software you write in it breaking over time as the language changes. if that's something you care about, common lisp is nice
Neo · 2021-08-09 07:06
>>27023
A standard is just a setting in stone of a norm of behavior which is "we don't break existing code".
Let's look at two new-ish languages, Scala and Clojure. Scala code notoriously breaks on new versions. Clojure code is very stable and you can run code written during Clojure 1.3 on 1.11.
The problem with a standard is it opens the door to competing implementations and tends to accrue dust over time.
Zuse · 2021-08-09 07:33
>>27033
I'm not saying that a standard is a guarantee of language stability -- another factor is the standard itself. if it's not adequate enough in scope, it'll result in a bunch of competing implementations with different features to make up for an overly minimal standard. scheme is a good example of this, but this isn't a problem that seems to afflict common lisp in my experience, either because the standard is adequate enough that different implementations don't need to add their own features, or because common lispers as a community have just created enough de facto standardized libraries to make up for things like lacking threads/regex/etc.
McCarthy · 2021-08-11 00:32
>>27034
Not her, but the CL spec is pretty small compared to those of other languages. The nice part about CL is that people can somehow agree to use wrapper libraries (e.g. bordeaux-threads) that will translate the programmer's code to whatever implementation it's running on, assuming the features are supported.
array · 2021-08-11 01:20
>>27076
That's interesting, I always hear people say that the CL spec is quite large and difficult to implement. It wouldn't surprise me if it was much larger than Scala and Clojure though.
Like I said before, the common lisper community just seems to have a culture that prioritizes maintaining portability among different implementations that has resulted in a lot of de facto libraries to solve things like threading etc. that are left out of the language standard but that modern programmers expect. I would imagine this is because common lisp itself was created because there were many different lisps with incompatible features, so that culture of maintaining portability has just lasted into the present day.
Arisu Mizuki · 2021-08-11 02:25
>>27077
For a Lisp, the CL spec is huge, sure. But even then it's not the largest: r7rs-large is projected to go well beyond the ANSI CL specification by the time it's finished.
The CL spec, compared to C++, for instance, is quite small and has a bunch of cases that lets implementations do whatever they want. There is an on-going effort to clarify these corners of the CL spec called WSCL that hopes to eventually fix this issue, though. I'd like to stress that WSCL is NOT intended to be a newer specification, though. It's simply trying to provide clarification of the CL spec in a way that matches what existing implementations already do (so there will be very little, if any work needed for current CL implementations to be compliant with WSCL).
>common lisp itself was created because there were many different lisps with incompatible features
Yeah, that sounds about right. CL was intended to somewhat unify the Lisps of its day in a way that provided minimal breakage in existing codebases.
However, people who come to CL from other languages tend to not give a single soykaf about portability and it's very annoying. They tend to just pick the most popular implementation and pretend nothing else exists.
Rick Deckard · 2021-08-11 20:36
I just finished A Gentle Introduction to Symbolic Computation and am wondering if I should continue with more detailed Common Lisp books or switch to Clojure. My concern, as a bad programmer who doesn't find programming intrinsically fun for its own sake, is whether Common Lisp or Clojure is better for getting things done.
I read a lot about libraries, Java background knowledge, debuggers, Javascript interface, etc, but as a beginner I have no sense of the real impact of these things.
For someone like me, which would you recommend?
Hong, Guil Dong · 2021-08-12 08:28
>>27087
Just stick with Clojure, since it will naturally have more libraries than any other Lisp out there. Common Lisp is good too and has a sizable chunk of libraries, but it doesn't have widespread adoption in industry like Clojure does. So that should tell you something about choosing between the two as a "bad programmer."
Lady Jessica · 2021-08-15 02:06
>>27078
Considering that the main appeal people usually point to scheme for is that it's really small and elegant, r7rs-large being projected to exceed the ANSI CL spec is really surprising. But I'm also not a schemer and frankly I don't have the best opinion of that community based on stuff like this and how fragmented all the different implementations are.
>WSCL
I hadn't heard of this but this seems like the kinda thing robert strandh would be working on. Hopefully it'll pick back up when SICL gets a release.
>However, people who come to CL from other languages tend to not give a single soykaf about portability and it's very annoying.
I've noticed that a lot of people just use SBCL by default, though admittedly I also have only used SBCL extensively because I haven't had a need for things like embedding in C or JVM interop. I try to keep all my code as close to the spec as possible and if I need something provided by SBCL I look for a library that satisfies my needs in a portable way, but at some point if I do a proper release of any of the projects I'm working on I'll have to setup a CI/CD pipeline to test against different CL implementations.
>>27087
if you don't really care about programming just use Clojure. it has industry support and its philosophy is basically to just rely on stuff that already exists and is supported by the industry and try to work with it in a way that is at least sane. it's nice for getting stuff done but nowhere near as powerful or cool as common lisp.
Drano · 2021-08-16 20:06
Anyone know why quicklisp still uses broken hash algorithms and no TLS?
The setup script doesn't even hash the list of hashes.
sizeof · 2021-08-16 20:20
>>27137
Mostly because it svcks and shouldn't be used.
Use Guix instead for managing Scheme and CL library depedencies.
Judge Fang · 2021-08-16 20:21
>>27138
*dependencies
> This correction message body is not too short.
Eldon Tyrell · 2021-08-16 20:43
>>27138
Guix is awful for CL dependencies. It completely ruins the common lisp development experience by forcing you into this static declarative non-CL world to manage that part of the program. If it had better integration with CL development I'd consider it, but I've tried it and didn't have a good experience with it.
There is however CLPM https://www.clpm.dev/ which seems like it'd meet the requirements of a proper package manager
progn · 2021-08-16 21:32
>>27141
While that's not completely wrong, I've had enough bad experiences with soykafty package management practices in a variety of languages that I try to use as few package managers as possible concurrently, and as few external dependencies as I can.
I tend to prioritize the security aspect of such programs a lot more than the convenience.
Joe Bloggs · 2021-08-16 21:58
>>27142
I tend to avoid using too many dependencies when writing CL programs, because you can get a lot done with ANSI CL anyways and having less dependencies means it's more likely to be portable and just werk forever. but that being said when I'm experimenting with stuff in the REPL I like being able to just install or load new stuff on the fly and with Guix it breaks me out of the CL zone.
I was experimenting with trying to making something similar to lorri but for Guix because Nix has bad support in general for CL and also I hate the fact that packaging stuff in it is essentially done with just shell scripts embedded in a weird DSL, but I ended up wasting too much time just trying to get a proper development environment together and stopped using Guix. if it turned out that CLPM didn't meet my needs or wasn't as nice as Guix (and I do like Guix in a lot of respects) I'd maybe consider going back to trying to make something like that again or just make something like Guix but written in CL and with first class support for a CL development experience.
Moore · 2021-08-19 22:33
1. random always gives the same number.
2. ^M is written to text file as ^M instead of newline.
I don't think ^M is an encoding problem because I don't type that, it's generated inside the script.
Both work correctly when run from inside the REPL.
Ideas?
Ender · 2021-08-19 22:36
>>27159
Forgot to say I'm using SBCL and bash.
list · 2021-08-21 23:34
>>27159
>RANDOM always gives the same number.
You probably want to initialize the RNG state to something fresh beforehand, otherwise it will always be the same as it was when your SBCL image was dumped every time you relaunch. Try something like (setf *random-state* (make-random-state t)) . See http://www.lispworks.com/documentation/HyperSpec/Body/f_random.htm.
>^M is written to text file as ^M instead of newline.
This is odd. ^M is a carriage return; the only way I can reproduce this on UNIX is by deliberately printing a #\CR, it doesn't seem SBCL has options for choosing the line terminator either. How are you printing the newline and/or opening the file?
pop · 2021-08-26 02:50
>>27190
>RNG state
Thanks, I forgot that "SBCL" is actually an image.
>^M
I figured out that the issue was just file formatting and nothing to do with SBCL.
>>27141
I can't seem to import his PGP key.
$ gpg --recv-keys 0x10327DE761AB977333B1AD7629932AC49F3044CE
gpg: key 0x29932AC49F3044CE: new key but contains no user ID - skipped
gpg: Total number processed: 1
gpg: w/o user IDs: 1
FILLER · 2021-08-26 09:41
Why is nthcdr not an accessor, at least in SBCL? I have to (cdr (nthcdr n list)) instead of just (nthcdr (1+ n) list)
Milner · 2021-08-26 21:19
>>27259
Both of your examples do the same thing. If you meant (car (nthcdr n list)) , that's what nth is for.
Zuse · 2021-08-26 23:48
>>26966
I completely agree, but then Rich Hickey couldn't strut on stage as he does.
>>26968
>They have nothing to do with one another
CLOS does account for much of the special situations he described with basic things such as EQL methods.
>Go watch Language Of The System before writing such silliness
I'll give this a look, but still know I'm right.
>>27033
>The problem with a standard is it opens the door to competing implementations and tends to accrue dust over time.
That's not a problem for anything but the poorest language standard written by fools.
>>27137
It's best to audit and download any dependencies manually. I only use dependencies I've also written.
藤原純一 · 2021-08-27 12:57
>>27271
I'm asking about accessors
Like, you can (setf (third list) whatever) and it will change the third element. Here, third is an accessor.
In SBCL and ECL, nthcdr is not an accessor. I can't just setf into nthcdr.
> (defparameter *x* '(1 2 3 4 5 6 7))
*X*
> (setf (nthcdr 3 *x*) '(3 . nil))
Condition of type: UNDEFINED-FUNCTION
The function (SETF NTHCDR) is undefined However, I can use car and cdr
>> (setf (cdr (nthcdr 2 *x*)) '(3 . nil))
(3)
>> *x*
(1 2 3 3) How come I can setf a cdr or cddddr, or even nth
(setf (nth 2 *x*) 5)
5
>> *x*
(1 2 5 3) But not an nthcdr? This feels odd
Faye Valentine · 2021-08-27 13:28
>>27299
It's easy to define your own setf accessors. If you think it should be in the language, you have the power to add it.
Personally, I tried to do this, but felt it was non-trivial and that the effort wasn't worth the gain (I'm not extremely familiar with the semantics of setf).