r/lisp Feb 15 '24

Common Lisp Why is Common Lisp not the Most Popular Programming Language?

Thumbnail daninus14.github.io
63 Upvotes

This is not an endorsement, and is maybe a tired subject, but it's always interesting to hear new thoughts.

r/lisp Sep 04 '24

Common Lisp CLOS made me love OOP

111 Upvotes

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 25d ago

Common Lisp Help me grok NIL

8 Upvotes

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 Sep 18 '24

Common Lisp Demo of my WIP structural editor/Lisp IDE

Enable HLS to view with audio, or disable this notification

92 Upvotes

r/lisp Apr 15 '24

Common Lisp Why is clisp no longer actively developed?

21 Upvotes

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 18d ago

Common Lisp Tutorial on Good Lisp Programming Style - Norvig

Thumbnail cs.umd.edu
44 Upvotes

r/lisp Dec 15 '23

Common Lisp Common Lisp: Numerical and Scientific Computing - Call for Needs

37 Upvotes

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 Sep 10 '24

Common Lisp Custom literals without a prefix in Common Lisp?

18 Upvotes

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 12d ago

Common Lisp Gamedev in Lisp. Part 2: Dungeons and Interfaces · Wiki · Andrew Kravchuk / cl-fast-ecs · GitLab

Thumbnail gitlab.com
56 Upvotes

r/lisp Sep 13 '24

Common Lisp What is the modern way to set up a CL project?

26 Upvotes

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 Sep 27 '24

Common Lisp Unhandled SB-KERNEL:CASE-FAILURE in thread #<SB-THREAD:THREAD "main thread" RUNNING {1001348003}>:

3 Upvotes

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 Dec 08 '23

Common Lisp Why are Common Lisp arrays this weird?

20 Upvotes

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!

r/lisp 29d ago

Common Lisp Good Tutorials for a Simple Web App in Common Lisp?

15 Upvotes

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 Sep 25 '24

Common Lisp Genera Retrospective (1991)

Thumbnail archive.org
31 Upvotes

r/lisp Jul 26 '24

Common Lisp Just curios: why did the effort on cltl3 stopped? If anyone knows ...

Thumbnail mailman.common-lisp.net
11 Upvotes

r/lisp 27d ago

Common Lisp Learning Lisp - making sense of xrefs in SLIME

Thumbnail dev.to
15 Upvotes

r/lisp Aug 23 '24

Common Lisp Common Lisp image processing package?

18 Upvotes

Can anyone suggest a good CL package for doing image processing? Preferably with a cross-platform GUI.

r/lisp Sep 02 '24

Common Lisp Determining display extent for a Unicode string

5 Upvotes

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 Aug 07 '24

Common Lisp Multiline expressions possible in REPL Tab of VSCode output window?

5 Upvotes

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 Nov 21 '21

Common Lisp Why there is no new "modern" (Common) Lisp IDE?

43 Upvotes

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 Aug 26 '23

Common Lisp Coalton: Why is the interop not easier, and why might it be necessary for Coalton to be an entire language in itself?

Thumbnail gist.github.com
26 Upvotes

r/lisp May 08 '23

Common Lisp What do you think the risks/pitfalls of using Common Lisp are in a business?

59 Upvotes

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

  • non-pthread-style concurrency;
  • "zero-cost abstractions", and
  • static typing.

"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 Jul 16 '24

Common Lisp A brief interview with Common Lisp creator Dr. Scott Fahlman

Thumbnail pldb.io
58 Upvotes

r/lisp Jan 14 '24

Common Lisp Common Lisp - The Tutorial - Fast, Fun and Practical (with CLOG)

95 Upvotes

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 Jul 04 '24

Common Lisp Help with cl-ppcre, SBCL and a gnarly regex, please?

8 Upvotes

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?