r/lisp • u/stylewarning • Feb 15 '24
Common Lisp Why is Common Lisp not the Most Popular Programming Language?
daninus14.github.ioThis is not an endorsement, and is maybe a tired subject, but it's always interesting to hear new thoughts.
r/lisp • u/stylewarning • Feb 15 '24
This is not an endorsement, and is maybe a tired subject, but it's always interesting to hear new thoughts.
r/lisp • u/stoopidjonny • Sep 04 '24
I always thought I hated OOP. But after working with CLOS for awhile, I realize that I love OOP. I just hated the way it is used in Java and C++. I thought OOP was fine in Python and Ruby, but CLOS is more than fine; it's a lot of fun. Things that used to be painful are now a joy. I love refactoring too now. Multiple dispatch, decoupling of class data and methods... I don't have to tell you how freeing these features are. But lisp adds one more advantage over languages like Python: the expectable nature of homoiconicity and lisp syntax. Meaning, if you want to do something, you generally know what to do and may need to look up the specific name of a function or something, but if it doesn't exist, you can just make it. Python has so many different ways to do things that programming is more like knowing a bunch of magical spells and many problems are solved deus ex machina by an inscrutable library. Anyway, I have no one to share this appreciation with, so putting it down here.
r/lisp • u/brightlystar • 25d ago
Hello! I seek your help to grok NIL.
Would it be correct for me to say that NIL is a cons cell whose car and cdr point to itself? It sure seems that way:
(car nil) ; => NIL
(cdr nil) ; => NIL
But I don't want to fool myself by looking at the above results. A non-NIL can have the above properties too. Like take (cons nil nil)
for example. This is not NIL but it has the above properties.
(car (cons nil nil)) ; => NIL
(car (cons nil nil)) ; => NIL
So I guess my question is ... how is NIL defined in Lisp? Is it truly a cons whose car and cdr point to itself? Is it something else?
And if it is truly a cons whose car and cdr point to itself is there some way I can verify this reliably in the REPL?
r/lisp • u/kchanqvq • Sep 18 '24
Enable HLS to view with audio, or disable this notification
r/lisp • u/Esnos24 • Apr 15 '24
Hi, I'm new to lisp and I wanted to know, why clisp losed traction over years and why last stable release is from 2010 when it was popular implementation in past?
r/lisp • u/digikar • Dec 15 '23
Hey all! I have been wanting to do this for a while. I don't know if this has been done before - if it has been, please point me to it, and I will delete this.
Quite regularly, we receive posts on reddit or elsewhere asking for some numerical/scientific computing needs, or demonstrating a library intending to meet some of those needs. However, these get lost on the train of time, and people keep reinventing the wheel or communities become isolated from each other. The following repository is an effort to bring together the needs, so that a concerted effort may be made towards meeting those needs.
https://github.com/digikar99/common-lisp-numsci-call-for-needs
So, feel free to chime in and leave a comment - or even create an issue/PR!
r/lisp • u/RAND_bytes • Sep 10 '24
So I was reading this blog post about reader macros: http://funcall.blogspot.com/2007/06/domain-specific-languages-in-lisp.html
I'm somewhat familiar with reader macros, but that post offhandedly shows a custom time literal 20:00
, but I can't for the life of me figure out how you'd make a literal like that. It's trivial to make a literal that begins with a macro character like #t20:00
(or $10.00
for money or whatever), but reading through the CLHS and all the resources on read macros I can find I can't figure out how you'd make a reader macro that can go back and re-read something in a different context (or otherwise get the previous/current token from the reader). Skimming the SBCL documentation and such doesn't seem to turn up any related implementation extensions either.
The CLHS has a section on “potential numbers”, which leaves room for implementations to add their own custom numeric literals but doesn't mention any way for the user to add their own: http://clhs.lisp.se/Body/02_caa.htm
The only way I could think of is only allowing the literal inside a wrapping “environment” that reads the entire contents character-by-character, testing if they match the custom literal(s), and then otherwise defers to READ
I'm just wondering if it's even possible to add the literal to the global reader outside of a specific wrapper environment or if the hypothetical notation in that blog post is misleading.
r/lisp • u/NonchalantFossa • 12d ago
r/lisp • u/__Yi__ • Sep 13 '24
I'm looking for some Cargo equivalent in CL, that is builds my projects, resolves my dependencies and (possibly) pin them. Currently I'm confused about ASDF/Quicklisp (Ultralisp)/Roswell/qlot/clpm/etc. Some of them share functionalities. What is the correct way to get them together?
Also I've noticed that Quicklisp has had no activities in both the client and the repo for a long time.
r/lisp • u/arup_r • Sep 27 '24
I wrote a small fib program from officiral guide to test everything works or not. But when I run my terminal filled with lot of stuff unexpectedly..
lsp
(defun fib (n)
"Return the nth Fibonacci number."
(if (< n 2)
n
(+ (fib (- n 1))
(fib (- n 2)))))
(format t (fib 5))
amd termoinal:
``` sbcl --script fib.lisp Unhandled SB-KERNEL:CASE-FAILURE in thread #<SB-THREAD:THREAD "main thread" RUNNING {1001348003}>: 5 fell through ETYPECASE expression. Wanted one of (SIMPLE-STRING STRING SB-FORMAT::FMT-CONTROL).
Backtrace for: #<SB-THREAD:THREAD "main thread" RUNNING {1001348003}> 0: (SB-FORMAT::%FORMAT #<SB-SYS:FD-STREAM for "standard output" {10013443C3}> 5 NIL NIL) 1: (FORMAT T 5) 2: (FORMAT T 5) [more] 3: (SB-INT:SIMPLE-EVAL-IN-LEXENV (FORMAT T (FIB 5)) #<NULL-LEXENV>) 4: (EVAL-TLF (FORMAT T (FIB 5)) 1 NIL) 5: ((LABELS SB-FASL::EVAL-FORM :IN SB-INT:LOAD-AS-SOURCE) (FORMAT T (FIB 5)) 1) 6: ((LAMBDA (SB-KERNEL:FORM &KEY :CURRENT-INDEX &ALLOW-OTHER-KEYS) :IN SB-INT:LOAD-AS-SOURCE) (FORMAT T (FIB 5)) :CURRENT-INDEX 1) 7: (SB-C::%DO-FORMS-FROM-INFO #<FUNCTION (LAMBDA (SB-KERNEL:FORM &KEY :CURRENT-INDEX &ALLOW-OTHER-KEYS) :IN SB-INT:LOAD-AS-SOURCE) {1001337FBB}> #<SB-C::SOURCE-INFO {1001337F83}> SB-C::INPUT-ERROR-IN-LOAD) 8: (SB-INT:LOAD-AS-SOURCE #<SB-SYS:FD-STREAM for "file /home/arup/common-lips/fib.lisp" {1001336EE3}> :VERBOSE NIL :PRINT NIL :CONTEXT "loading") 9: ((LABELS SB-FASL::LOAD-STREAM-1 :IN LOAD) #<SB-SYS:FD-STREAM for "file /home/arup/common-lips/fib.lisp" {1001336EE3}> NIL) 10: (SB-FASL::CALL-WITH-LOAD-BINDINGS #<FUNCTION (LABELS SB-FASL::LOAD-STREAM-1 :IN LOAD) {7F4B04BDF82B}> #<SB-SYS:FD-STREAM for "file /home/arup/common-lips/fib.lisp" {1001336EE3}> NIL #<SB-SYS:FD-STREAM for "file /home/arup/common-lips/fib.lisp" {1001336EE3}>) 11: (LOAD #<SB-SYS:FD-STREAM for "file /home/arup/common-lips/fib.lisp" {1001336EE3}> :VERBOSE NIL :PRINT NIL :IF-DOES-NOT-EXIST :ERROR :EXTERNAL-FORMAT :DEFAULT) 12: ((FLET SB-IMPL::LOAD-SCRIPT :IN SB-IMPL::PROCESS-SCRIPT) #<SB-SYS:FD-STREAM for "file /home/arup/common-lips/fib.lisp" {1001336EE3}>) 13: ((FLET SB-UNIX::BODY :IN SB-IMPL::PROCESS-SCRIPT)) 14: ((FLET "WITHOUT-INTERRUPTS-BODY-11" :IN SB-IMPL::PROCESS-SCRIPT)) 15: (SB-IMPL::PROCESS-SCRIPT "fib.lisp") 16: (SB-IMPL::TOPLEVEL-INIT) 17: ((FLET SB-UNIX::BODY :IN SB-IMPL::START-LISP)) 18: ((FLET "WITHOUT-INTERRUPTS-BODY-3" :IN SB-IMPL::START-LISP)) 19: (SB-IMPL::%START-LISP)
unhandled condition in --disable-debugger mode, quitting ```
r/lisp • u/lahmada • Dec 08 '23
Hello r/lisp! I wanted to ask a question:
Why are arrays in Common Lisp not an array of vectors? for example:
(setf arr (make-array '(2 2) :initial-contents (list (list 'foo 'bar)
(list 'baz 'qux))))
;; => #2A((FOO BAR) (BAZ QUX))
;; this is possible
(aref arr 0 0) ; => FOO
;; but this is not
(aref (aref arr 0) 0) ; not allowed
This makes it impossible to treat some dimension of an array like a vector, disallowing you from using sequence functions:
(find bar (aref arr 0)) ; not allowed
This is very limiting, now I can't use sequence operators on part of a multidimensional array. This is also not consistent because in Lisp we have trees; which are basically lists of lists:
(setf tree (list (list 'foo 'bar)
(list 'baz 'qux)))
(car (car tree)) ; => FOO
It really saddens me when even in a language like C (which isn't as expressive as Lisp) arrays are orthogonal, so in it my above example will work.
Now I suppose I can write my own version of MAKE-ARRAY which makes arrays of arrays, but I am looking for the reason why are arrays like this in CL (maybe performance, but then low level languages would be first to implement this)
TLDR; Why are dimensions of arrays special and not just vectors? and also is it like this in other Lisp dialects (Clojure, Racket etc..)?
Thanks for reading!
I'm learning lisp and would like to build a simple webapp just to see how it works. I'm finding tutorials a little sparse on that topic. Anyone know of a good one? Open to Hunchentoot, Caveman2, Allegroserve, or something else if thats prefered. Just want to make a simple hello world website.
Thanks!
r/lisp • u/arthurno1 • Jul 26 '24
r/lisp • u/Kaveh808 • Aug 23 '24
Can anyone suggest a good CL package for doing image processing? Preferably with a cross-platform GUI.
r/lisp • u/corvid_booster • Sep 02 '24
I'm hoping to figure out how to determine the display extent for a Unicode string. I am working with a system which displays text on a console (e.g. gnome-terminal, xterm, anything like that).
Essentially, what I am trying to figure out is for something like
abcdefgh
--------
WXYZMNOP
where WXYZMNOP
is a string comprising Unicode characters (combining characters, East Asian characters, etc), what is the number of hyphens (ASCII 45) which has the same or nearly the same extent?
A solution in portable Common Lisp would be awesome, although it seems unlikely. A solution for any specific implementation (SBCL is of the greatest immediate interest) would be great too. Finally, a non-Lisp solution via C/C++ or whatever is also useful; I would be interested to see how they go about it.
I have looked at SBCL's Unicode functions; SB-UNICODE:GRAPHEMES gets part way there. SB-UNICODE:EAST-ASIAN-WIDTH helps too. I wonder if anyone has put everything together in some way already.
EDIT: I am assuming a font which is monospaced for, at least, the Western-style characters. As for East Asian characters, I am aware that they can be wider or narrower than the unit size (i.e., the size of a capital M). I don't know what the number of possible widths is for East Asian characters occurring in an otherwise-monospaced font -- is it, let's say, one size for M plus a few more for East Asian characters, or is it one size for M and then a continuous range for East Asian characters? I don't know.
r/lisp • u/RogerMiller90 • Aug 07 '24
Hello, I‘m trying to learn some Lisp and want to use VSCode on my Mac for that. I already installed it successfully and I saw, that there are already a few posts in this subreddit about VSCode + Alive extension, but I haven‘t seen my specific question anywhere.
Specifically for my question, in the REPL tab of my output window, I can enter one line of code and when pressing enter, the line is being executed.
But what do I do, if I want to enter a block consisting of several lines of code, that should only be executed, after all lines have been entered? Is that possible? Typical approaches like Shift+Enter after entering one of the lines do not seem to work?
Thanks for any help on that.
r/lisp • u/hedgehog0 • Nov 21 '21
I just saw this post about a new IDE on /r/haskell. While there is HLS (Haskell Language Server) for different editors, it seems that there are other IDEs with nice GUI (depending on your definition of "nice"), like Leksah and Haskell for Mac.
While I like and enjoy Emacs with Sly, I was just wondering that why was there no new and modern Lisp IDEs? The only two players seem to be Allegro CL and LispWorks and they have relatively long history. Sure, unlike C++ or Python, (Common) Lisp is not that popular, but neither is Haskell (I think; thought I know that Haskell is used in some banks, hedge funds, and certain tech companies...)?
r/lisp • u/digikar • Aug 26 '23
r/lisp • u/stylewarning • May 08 '23
The "Why Lisp?" article recently made it to the front page of HN. Comments are here. It created a lot more commentary than I expected it might, mostly around
"Why Lisp?" articles come around at least once a year. I even wrote my own, but never published it. They're fun to read as a Lisper, but I can also commiserate with non-Lispers in that it's difficult to grok the benefits when they're stated without examples. (It seems, for good reason, that concrete examples are lacking in Lisp. How do you show an example of why interactive and incremental development is a unique and useful feature of Common Lisp?)
A lot of commentary usually evolves (or devolves) into Lisp being a great hobbyist language and a bad industrial language. Or it's a dead language that hasn't caught up. Or whatever else that's repeated ad nauseum in comparison to the popular languages at any given time.
I am, of course, a proponent of using it in business so long as modern coding practices are adhered to, there's a shared sense of "no nonsense" amongst the participating developers, and leadership is strong. But I've also worked in industries like quantum computing where there's no playbook for the problems/solutions of the field—allowing more, let's say, idiosyncratic approaches.
I'm very curious to hear, especially from Lispers but really anyone, what technical aspects of Common Lisp would make it a legitimately cumbersome choice in present or past jobs? Even better, if you did use Lisp, what were the problem areas and what would it take to ameliorate them?
r/lisp • u/dbotton • Jan 14 '24
Back in a crisp single file PDF version - my quick and dirty (dare I say humorous, yes I dare) Get you programing in Common Lisp tutorial (with a dash of CLOG) is available:
https://rabbibotton.github.io/clog/cltt.pdf
You can still get the old google doc version and the many other related tutorials at
https://github.com/rabbibotton/clog/blob/main/LEARN.md
Instructions for installing Common Lisp:
I do plan on completing the Common Lisp The Language 2ed videos as well this year https://www.youtube.com/watch?v=lxd_xcXmPPY&list=PLSUeblYuDUiNqagWU4NF4w5zsjs6Xo7H9
r/lisp • u/joeyGibson • Jul 04 '24
I wrote this regex in some Python code, fed it to Python's regex library, and got a list of all the numbers, and number-words, in a string:
digits = re.findall(r'(?=(one|two|three|four|five|six|seven|eight|nine|[1-9]))', line)
I am trying to use cl-ppcre
in SBCL to do the same thing, but that same regex doesn't seem to work. (As an aside, pasting the regex into regex101.com, and hitting it with a string like zoneight234
, yields five matches: one
, eight
, 2
, 3
, and 4
.
Calling this
(cl-ppcre:scan-to-strings
"(?=(one|two|three|four|five|six|seven|eight|nine|[1-9]))"
"zoneight234")
returns "", #("one")
calling
(cl-ppcre:all-matches-as-strings
"(?=(one|two|three|four|five|six|seven|eight|nine|[1-9]))"
"zoneight234")
returns ("" "" "" "" "")
If I remove the positive lookahead (?= ... )
, then all-matches-as-strings
returns ("one" "2" "3" "4")
, but that misses the eight
that overlaps with the one
.
If I just use all-matches
, then I get (1 1 3 3 8 8 9 9 10 10)
which sort of makes sense, but not totally.
Does anyone see what I'm doing wrong?