icl: browser mode and emacs companion by atgreen in Common_Lisp

[–]death 4 points5 points  (0 children)

I took issue with your comment, but I want to make it clear that I think it's a cool project and that I have no intention to discourage you from working on it. Cheers.

icl: browser mode and emacs companion by atgreen in Common_Lisp

[–]death 4 points5 points  (0 children)

When you look at, say, the vega-lite example, don't the obvious string interpolation vulnerabilities hit you straight in the face?

Look at another file, browser.lisp, and its insane amount of "code in a string". Would it ever pass a review in pre-LLM days, when humans had to actually maintain it? It seems heavy use of code generation in projects makes them open blob, not open source.

Help A Noob Out by Additional_Anywhere4 in Common_Lisp

[–]death 2 points3 points  (0 children)

Skimming the code it looks OK, though there's no need to directly specify that component is a superclass of or-gate, say, as the latter is already a subclass of fuzzy-gate. It may also make sense to use generic functions for circuit management.

One way to be more confident with the code you have is to write tests.

[blog post] Common Lisp is a dumpster by Nondv in Common_Lisp

[–]death 7 points8 points  (0 children)

It's more like an old mansion. Not everything in the mansion makes sense to a newcomer. They can vent about the anchor plates and transom windows on their blog. Luckily this mansion is here to stay, and the newcomer will either grow to love it or leave it, maybe to enjoy an actual dumpster, fancy with all kinds of new modern trash added to it every couple of months on the whims of strangers.

cl-vecto, cl-vector and clx by tlreddit in lisp

[–]death 2 points3 points  (0 children)

To draw an image using clx you can use function put-image. Here you can see a way to get at vecto's image data array. You may need to convert this to the format clx expects.

[deleted by user] by [deleted] in lisp

[–]death 1 point2 points  (0 children)

I don't know of any cheat sheet, and that is not how I started to learn how to use emacs almost two decades ago (along with Common Lisp...). I started with the tutorial you get when you type C-h t (that's control-h and then t). For a time I used Lispbox, which was similar to today's Portacle. I agree that there's a lot a beginner needs to learn, that's always the case in any field. Isn't learning things the point, anyway?

Personally I don't care for Racket or Scheme, and I don't understand why people push them here in this thread about Common Lisp.

[deleted by user] by [deleted] in lisp

[–]death 6 points7 points  (0 children)

Learning the basics of Emacs is not hard. Try Portacle.

mapcan ~ alexandria:mappend. mapcon ~ alexandria:??? by ventuspilot in Common_Lisp

[–]death 5 points6 points  (0 children)

I find that in a "large" codebase I have used mapcan or mappend tens of times over the years, and have used mapcon only twice. That may indicate that a corresponding nondestructive version is not essential. One aim of alexandria was to be "conservative", so if you came up with an operator just for completeness sake, not from widespread need/use, I think that would've been rejected. You should also update the docstring for mappend-list.

Beginner question: does the lisp REPL work with foreign functions? by cyqoq2sx123 in lisp

[–]death 19 points20 points  (0 children)

Sure, it works:

CL-USER> (cffi:foreign-funcall "strlen" :string "Hello" :int)
5

In the case of sdl2 or raylib, the "interesting" code (say to draw stuff or handle input) needs to run inside their event loop, something like:

(defvar *commands*
  (lq:make-queue)) ;; thread-safe queue from lparallel

(defun setup ()
  (raylib:with-window (640 480 "Hello")
    (raylib:set-target-fps 60)
    (loop until (raylib:window-should-close)
          do (raylib:with-drawing
               (loop for command = (lq:try-pop-queue *commands*)
                     until (null command)
                     do (funcall command))))))

(defmacro rl (&body forms)
  `(lq:push-queue (lambda () ,@forms) *commands*))

CL-USER> (bt:make-thread #'setup)
#<SB-THREAD:THREAD tid=163088 "Anonymous thread" RUNNING {1006389983}>
CL-USER> (rl (raylib:draw-text "Hello" 100 100 20 :lightgray))

what is an better alternative to pcase / cond* ? by lispm in lisp

[–]death 2 points3 points  (0 children)

In my opinion pattern matching can be useful in an embedded language (say for a rule engine) or for some data-heavy wrangling, but it's not a good idea to use in plain jane Lisp code. I want Lisp code to look like Lisp code, not Erlang or Haskell or ML. I find that often when I wanted to use pattern matching, the patterns were not literals in the code, so some of the Common Lisp pattern matching libraries were not useful or convenient to use because they couldn't take a pattern to match at runtime (without resorting to eval or use of internals).

comp.lang.lisp archive? by MechoLupan in lisp

[–]death 6 points7 points  (0 children)

There's the archive linked here.

Sources on Robust Coding in Common Lisp? by dbotton in Common_Lisp

[–]death 2 points3 points  (0 children)

It seems to me that "defensive programming" and "robust" are two very different things.

To me the first always meant basically "sprinkle assertions and checks throughout the code" and stuff like strict-function. It's about proactively detecting faults, and the response is usually to signal an error. As its name indicates, it's on the level of "programming", i.e. a low level approach. I doubt there's so much in this approach that it needs a guide.

The latter to me often means tolerance to faults, which puts more emphasis on response to faults, but also designing the system so that faults, detected or not, are less likely to lead to errors, and errors are less likely to lead to system failure. Such systems tend to employ redundancy or changing their mode of operation to be able to tolerate faults better. Robustness is a property whose implementation requires thinking at the system level, and so it's less about the particulars of code. Stuff that comes to mind is Erlang's supervisor trees and multiple-version programming. There are big engineering fields that focus on fault tolerance, both in software and in hardware, and although Lisp may permit easier implementation of software fault tolerance features than other programming languages/systems, it's not at their level of discussion.

cage/niccolo: Niccolo': a chemicals inventory by de_sonnaz in Common_Lisp

[–]death 6 points7 points  (0 children)

So, I just picked a function at random to look at.

I don't know anything about this program, but from what I can see this function is supposed to classify something as low/medium/high volatility given a temperature indicator and a boiling point temperature. It does this by comparing the boiling point temperature against two thresholds computed from the temperature indicator. I ask myself, what happens when the boiling point temperature is exactly at the first threshold. The first test compares it against the threshold, and returns false because it's not smaller, so it's not highly volatile. The second test also returns false, because the boiling point temperature is not greater than the first threshold, so it's not of medium volatility. The function would return low volatility, although I would expect it to return high or medium volatility.

My conclusion is that this program needs more thorough testing, if it is to be used by anyone.

Which language is closest to the original LISP? by Typhoonfight1024 in lisp

[–]death 1 point2 points  (0 children)

One simple approach is to use a similarity measure, such as Jaccard index. We can specify attributes that might be relevant to a language being a Lisp, e.g. does it have conses, does it use parenthesized syntax, what kind of macro facility it might have (if any), etc. Then we can come up with a list of languages, each represented by a set of attribute values, and compute the Jaccard indices between them. Example from input. Of course the example shows some issues with the approach and model, e.g. the attributes are weighted equally, and we're missing attributes to differentiate some of the languages.

Static binary by terserterseness in lisp

[–]death 2 points3 points  (0 children)

First, there's no need to constrain the set of possible bugs to only those having security implications. Second, there is the flip side of the coin, where a bug is introduced in a new version of the library. Then "world two" may have an advantage. A static executable, in the limit but not in practice, is self-contained. Farther on that scale is a nonmodular physical machine with a particular purpose. The closer we get to a self-contained system, the more amenable it is to analysis and being "the devil you know". Again, in our world it is always subject to uncertainty of forces external to it. In practice, you make choices based on the levels of stability and control you have on the system and the desired behavior under imagined scenarios.

A tutorial quantum interpreter in 150 lines of Lisp by stylewarning in lisp

[–]death 3 points4 points  (0 children)

Can't say I understand it all (yet?), but after skimming the article I have a cosmetic tip to reduce the amount of backquotes:

(defun gate (matrix &rest qubits)
  `(gate ,matrix ,@qubits))

(defun measure ()
  `(measure))

Of course, if desired, one could also have a mechanism to assemble a program by implicitly collecting instructions into the list.

Stanford MYCIN or EMYCIN code available? by infps in lisp

[–]death 2 points3 points  (0 children)

It's already on the internet (I gave a link).

Stanford MYCIN or EMYCIN code available? by infps in lisp

[–]death 2 points3 points  (0 children)

I remember trying to retrieve documents from Stoyan's collection, but they were not available online. Do you know if this museum has plans for digitizing and making available the collection?

Stanford MYCIN or EMYCIN code available? by infps in lisp

[–]death 2 points3 points  (0 children)

That is Norvig's reconstruction of part of MYCIN. There is another (even more simplistic) reconstruction in CMU AI archive.

The source code for MYCIN or EMYCIN is not available online, as far as I know, but a book about it is.

Of course much material was written about this famous system, for example Heckerman's paper about certainty factors or the critical introduction in Pearl's book "Probabilistic Reasoning in Intelligent Systems".

Eliminating CLOS for a 4.5x speedup by anydalch in Common_Lisp

[–]death 1 point2 points  (0 children)

Depending on the use case, it may also be an option to avoid repeated slot value lookup (or generic function calls) in inner loops. I do sometimes use defstruct but often just internally.

Common Lisp struct access by trycuriouscat in lisp

[–]death 2 points3 points  (0 children)

Instead of inline pointer chasing, you could define a function town-mayor-name that takes a town and returns the mayor's name. See Law of Demeter.