News for hackers. Stuff that matters.
Re:Pattern Matching and Tail Recursion in Emacs Lisp by gigatexal on Friday November 25, 2022 @02:06AM (#33739996)
I want to get my head wrapped around lisp but I just see code like this and my head hurts
Re:Pattern Matching and Tail Recursion in Emacs Lisp by lispm on Friday November 25, 2022 @02:37AM (#33740149)
It's unfamiliar to the beginner and could take also some "unlearning" of expectations how a program looks like and how to program.

But there are reasons for the syntax: it allows relatively easy language extensions. The mentioned PCASE macro extends the language with a pattern matching construct. Every user can write theses things. Directly in Lisp, without modifying the language itself - because it is already extensible.

The source for PCASE is here: https://github.com/emacs-mirror/emacs/blob/master/lisp/emacs...

Emacs Lisp has some well written extensions. I find the coding style of something like the PCASE extension to be quite readable, for me as a Lisp user. ;-)

Re:Pattern Matching and Tail Recursion in Emacs Lisp by tetris11 on Friday November 25, 2022 @02:32AM (#33740126)
I think there's an inherent beauty to Lisp, but when I see backquote/comma expansion commas it upsets this idea for me. I wish they chose other symbols for this
Re:Pattern Matching and Tail Recursion in Emacs Lisp by abecedarius on Friday November 25, 2022 @09:45AM (#33742801)
Do you have an alternative design you like?

(Not a gotcha. I have my own Lisp dialect and I'm willing to mess with the syntax.)

Re:Pattern Matching and Tail Recursion in Emacs Lisp by tetris11 on Sunday November 27, 2022 @12:35PM (#33764761)
maybe using triangle brackets instead on statements that need to be immediately evaluated
Re:Pattern Matching and Tail Recursion in Emacs Lisp by jdale27 on Friday November 25, 2022 @02:30AM (#33740113)
I wouldn't call this everyday Lisp code for beginners. Try Practical Common Lisp: https://gigamonkeys.com/book/.
Re:Pattern Matching and Tail Recursion in Emacs Lisp by medo-bear on Friday November 25, 2022 @05:25AM (#33741033)
common lisp gentle introduction - begginer programmer

practical common lisp - intermediate programmer

paradigms of artifical intelligence programming - advanced programmer; also one of the best books on software engineering ever written even if you dont care much for lisp

all free. the latter has a new markdown edition

Re:Pattern Matching and Tail Recursion in Emacs Lisp by dwringer on Friday November 25, 2022 @11:59AM (#33744344)
Hopefully it's not just gauche nowdays to recommend it here, and that I've not been led astray, but I think ANSI Common Lisp and On Lisp are a great introduction sequence and I recommend them both to anyone who wants a methodical but gentle introduction. Among many highlights, the first one has a chapter on raytracing that I found truly impressive in its brevity and significance.
Re:Pattern Matching and Tail Recursion in Emacs Lisp by Archelaos on Friday November 25, 2022 @07:14AM (#33741683)
I would like to give Common Lisp a try. What setup/frameworks are best for a beginner targeting Win10 GUI apps (ideally self-contained in a single exe) that need to access a MariaDB server over the Internet?
Re:Pattern Matching and Tail Recursion in Emacs Lisp by mark_l_watson on Friday November 25, 2022 @10:01AM (#33742961)
I don’t use Windows, but LispWorks is well supported on Windows, macOS, and Linux. I bought the macOS version and pay the yearly maintenance fee. It has a good portable GUI library called CAPI and creates small standalone executables.

LispWorks is expensive so try the free version for a long time to make sure it is right for you.

For macOS and Linux, the open source SBCL is excellent and there are libraries to use TK or web apps as GUI interfaces.

Re:Pattern Matching and Tail Recursion in Emacs Lisp by dwringer on Friday November 25, 2022 @11:34AM (#33744028)
I'll second that Tk works well with SBCL in such an environment without much hassle (although a web app GUI is a great route), the libraries may not all be up to date with the latest features but it's relatively straightforward to implement them looking at the source code as a template. With CFFI one can get into the windows API pretty readily as well, so the sky's pretty much the limit.

As far as being self-contained it's at least easy enough to get everything within a single project directory, and if you don't rely on tcl or something external like that then one should be able to load pretty much everything into the image and save it as an .exe.

Re:Pattern Matching and Tail Recursion in Emacs Lisp by tmtvl on Friday November 25, 2022 @11:51AM (#33744248)
Probably LTK and CLSQL. Accessing a MySQL (well, MariaDB is a drop-in replacement) DB over the internet is no different from accessing it locally.

If you don't like Tk, there's a few alternatives like IUP or Qtools.

Of course if you'd prefer you could grab Armed Bear, use Java libraries, and export a JAR. In that case you can use Swing and JDBC.

Re:Pattern Matching and Tail Recursion in Emacs Lisp by fredrikholm on Friday November 25, 2022 @02:14AM (#33740032)
Highly recommend Clojure(Script) as a nice introduction to Lisps. It has slightly more syntax (square and squiggly brackets) to avoid having to use an army of parens to denote destructuring, binding etc.
Re:Pattern Matching and Tail Recursion in Emacs Lisp by medo-bear on Friday November 25, 2022 @04:02AM (#33740581)
i think common lisp has much better learning material. although it has been a while since i last looked, there isnt really anything beginner friendly for clojure

beginners would do well to look at COMMON LISP: A Gentle Introduction to Symbolic Computation. it's easy going and you i think everything you learn you can quite easily translate to other lisps

Re:Pattern Matching and Tail Recursion in Emacs Lisp by Ligma123 on Friday November 25, 2022 @04:25AM (#33740708)
>there isnt really anything beginner friendly for clojure

How about Brave Clojure?

https://www.braveclojure.com/

Re:Pattern Matching and Tail Recursion in Emacs Lisp by medo-bear on Friday November 25, 2022 @04:57AM (#33740907)
probably a good book about clojure and what makes it stand out, but in my opinion it isn't a good introduction to lisp per se
Re:Pattern Matching and Tail Recursion in Emacs Lisp by coutego on Friday November 25, 2022 @01:01PM (#33745072)
I'd say that Racket makes for an easier introduction to Lisps, at least for people not familiar with the functional paradigm.

The reason for this is that Clojure intentionally discourages many common imperative idioms by not making any effort to support them. That forces you to learn how to do things "the Clojure way". Once you know it, you realise it makes sense and it's a better way to do thing in that context, but when you are coming from outside, it can be very hard to get things.

At least it was for me, after some 20 years of programming experience. Racket? Sure, I was able to do (simple) programs without too many problems in a matter of hours. Clojure? Lots of "huh?" moments for months until the "aha" moment when things makes complete sense.

I'm quite a big fan of Clojure, for full context.

Re:Pattern Matching and Tail Recursion in Emacs Lisp by agumonkey on Friday November 25, 2022 @02:19AM (#33740058)
it's mostly just induction over trees with a few old idioms for matching
Re:Pattern Matching and Tail Recursion in Emacs Lisp by medo-bear on Friday November 25, 2022 @03:39AM (#33740458)
this is not beginner code, lisp or otherwise. you are looking at macros. macros are a very powerful programming feature, and no other programming language excells at writing macros to lisp level. moreover writing macros might not be very elegant compared to other code. however writing macros in lisp certainly is much more elegant compared to what you need to do to achieve the same result in other languages. the point of writing macros is to make calling them elegant
Re:Pattern Matching and Tail Recursion in Emacs Lisp by neilv on Friday November 25, 2022 @04:50AM (#33740862)
Don't get intimidated. This article doesn't much get into explanation.

Understanding `match`-like syntax takes some explanation, and then the syntax can sometimes still look intimidating, especially if they added in lots of conveniences. But once you read through the docs, it's usually trivial, and can eliminate a lot of bulky and error-prone code.

Named-`let` in Scheme (which is what I suspect inspired this Emacs `named-let`) looks confusing until you know it. As you try to write Scheme code without mutating variables (setting variables to new values after they already had one) as a stylistic choice, named-`let` and properly-implemented tail calls get very useful. And once you've used it a little, it's simple, and tail recursion will usually be easy to follow (easier than trying to follow code setting flag variables, having premature exits, etc.).

These are actually two very-very different kinds of constructs. `match` ends up being a kind of mini-language with some syntactic sugar thrown in, but named-`let` is more a fundamental construct.

Re:Pattern Matching and Tail Recursion in Emacs Lisp by hddqsb on Friday November 25, 2022 @04:57AM (#33740908)
As others have said, this article is not beginner-friendly. The book "Structure and Interpretation of Computer Programs" (SICP) is a classic introduction to Lisp (specifically Scheme), the full text is available online: https://mitp-content-server.mit.edu/books/content/sectbyfn/b...
Re:Pattern Matching and Tail Recursion in Emacs Lisp by medo-bear on Friday November 25, 2022 @05:21AM (#33741016)
great book but not an introduction to lisp
Re:Pattern Matching and Tail Recursion in Emacs Lisp by hibbelig on Friday November 25, 2022 @09:42AM (#33742783)
It's an introduction to programming, and thus to Lisp. No?
Re:Pattern Matching and Tail Recursion in Emacs Lisp by kagevf on Monday November 28, 2022 @11:53PM (#33783839)
More like an introduction to computer science concepts.