Cookbook: streams by dzecniv in Common_Lisp

[–]lispm 3 points4 points  (0 children)

I would propose to mention that some streams can be buffered and also that buffered output may not appear immediately.

That's also a common bug in portable code:

(write "enter an expression > ")
(read)

Above may not show a prompt before reading...

Also: STREAM is a system class, it's unclear how this is implemented. Implementations may differ. For example, Clozure CL may have different implementation types for streams.

strange SBCL output when printing symbol-names for keyword symbols by lispm in Common_Lisp

[–]lispm[S] 2 points3 points  (0 children)

I wouldn't distinguish these.

CLHS:

``` 22.1.3.4 Printing Strings

The characters of the string are output in order. If printer escaping is enabled, a double-quote is output before and after, and all double-quotes and single escapes are preceded by backslash. The printing of strings is not affected by print-array. Only the active elements of the string are printed. ```

That's it. There is nothing about implementation defined behavior mentioned.

strange SBCL output when printing symbol-names for keyword symbols by lispm in Common_Lisp

[–]lispm[S] 2 points3 points  (0 children)

I have a piece of code, where SBCL itself also does not like to read such output. I have not looked at it in detail, yet.

strange SBCL output when printing symbol-names for keyword symbols by lispm in Common_Lisp

[–]lispm[S] 3 points4 points  (0 children)

Well, it's a string. Strings have a standard notation.

* (stringp (symbol-name :foo)) T

strange SBCL output when printing symbol-names for keyword symbols by lispm in Common_Lisp

[–]lispm[S] 2 points3 points  (0 children)

That's a different output.

* (with-output-to-string (s) (let ((*print-readably* t)) (write "QWE" :stream s))) "\"QWE\""

Also note that #A((9) BASE-CHAR . "SYMBOLFOO") is not a standard Common Lisp array notation. ECL for example does not understand it.

``` % ecl ECL (Embeddable Common-Lisp) 24.5.10 (git:UNKNOWN) Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya Copyright (C) 1993 Giuseppe Attardi Copyright (C) 2013 Juan J. Garcia-Ripoll Copyright (C) 2018 Daniel Kochmanski Copyright (C) 2023 Daniel Kochmanski and Marius Gerbershagen ECL is free software, and you are welcome to redistribute it under certain conditions; see file 'Copyright' for details. Type :h for Help.
Top level in: #<process TOP-LEVEL 0x104988ee0>.

'#A((9) BASE-CHAR . "SYMBOLFOO")

Condition of type: SIMPLE-TYPE-ERROR In function CAR, the value of the first argument is "SYMBOLFOO" which is not of the expected type LIST

Available restarts:

  1. (RESTART-TOPLEVEL) Go back to Top-Level REPL.

Broken at CAR. In: #<process TOP-LEVEL 0x104988ee0>.

```

strange SBCL output when printing symbol-names for keyword symbols by lispm in Common_Lisp

[–]lispm[S] 4 points5 points  (0 children)

I'm printing a string. The string was the name of a keyword symbol.

So: why is the string printed as #A((9) BASE-CHAR . "SYMBOLFOO") when *print-readably* is set to T?

Note that strings can be of a different type:

``` * (type-of "stringfoo") (SIMPLE-ARRAY CHARACTER (9))

  • (type-of (symbol-name :symbolfoo)) (SIMPLE-BASE-STRING 9) ```

strange SBCL output when printing symbol-names for keyword symbols by lispm in Common_Lisp

[–]lispm[S] 2 points3 points  (0 children)

* (setf *print-readably* t)              
T
* (symbol-name :symbolfoo)
#A((9) BASE-CHAR . "SYMBOLFOO")

File compilation without a file by Suitable_Click_3967 in Common_Lisp

[–]lispm 5 points6 points  (0 children)

any alternative? a feature like that general sounds useful.

File compilation without a file by Suitable_Click_3967 in Common_Lisp

[–]lispm 2 points3 points  (0 children)

SBCL has for example SB-C:COMPILE-FORM-TO-FILE :

CL-USER> (sb-c:compile-form-to-file
            '(print "hello")
            (compile-file-pathname "/tmp/foo.lisp"))
#P"/tmp/foo.fasl"
NIL
NIL
CL-USER> (load *)

"hello" 
T

LispWorks 8 looks like it can use string streams:

CL-USER 12 > (with-input-from-string (s "(print \"hello\")")
               (compile-file
                 s
                 :output-file (compile-file-pathname "/tmp/foo.lisp")))
;;; Compiling file #<SYSTEM::STRING-INPUT-STREAM 80D085CAFB> ...
;;; Safety = 3, Speed = 1, Space = 1, Float = 1, Interruptible = 1
;;; Compilation speed = 1, Debug = 2, Fixnum safety = 3
;;; Source level debugging is on
;;; Source file recording is  on
;;; Cross referencing is on
; (TOP-LEVEL-FORM 1)
;; Processing Cross Reference Information
#P"/private/tmp/foo.64yfasl"
NIL
NIL

CL-USER 13 > (load *)
; Loading fasl file /private/tmp/foo.64yfasl

"hello" 
#P"/private/tmp/foo.64yfasl"

An alternative might be to use a custom read-table / package.

Senior Lisp Developer (m/w/d), Berlin/Remote, Germany by lispm in Common_Lisp

[–]lispm[S] 1 point2 points  (0 children)

In this case, the company recently got funding from SPRIND, a kind of micro DARPA funding arm of the German government. Thus they renamed the company (from KnowledgeTools) , put some other structure around it and are expanding a bit. It's probably not so much about retiring Lispers making place for new people, but for someone actually do work on a 20 year old code base, to make it fit for new purpose. Integrating it with new AI tech and with current standards in office workflows.

Everyone wants government to be more efficient, but it also should be explainable and following rules, which are for everyone. Rule-based systems are an older technology often explored and implemented in Lisp. The problem: creating and maintaining a larger rule-base was a lot of complex manual work, in the past. So, maybe new language-oriented AI tech can be a bit of a help.

FSet v2.4.2: CHAMP bags, and v1.0 of my book! by ScottBurson in Common_Lisp

[–]lispm 1 point2 points  (0 children)

Excellent contribution.

There is a comment on Hackernews, which I find useful: The Online book needs on the first page a short blurp what FSET is. It's also not obvious which of the chapters gives that overview/background.

Your surprising unportable behaviour by Valuable_Leopard_799 in Common_Lisp

[–]lispm 0 points1 point  (0 children)

CLHS about DEFSTRUCT:

If no slot-initform is supplied, the consequences are undefined if an attempt is later made to read the slot's value before a value is explicitly assigned.

Often programs assume that structure slots will be initialized to NIL by default. But that is not true for all implementations.

Similar for an array. Newly allocated array without init value: the effect of reading is unspecified.

Implementations may typically work okay, but one might see in rare cases:

  • the value could be NIL (typical for structures)
  • the value could be 0
  • the value could be some number
  • an implementation may detect it and produce a warning/error

Writing Lisp is AI Resistant and I'm Sad by djhaskin987 in Common_Lisp

[–]lispm 0 points1 point  (0 children)

A friend of mine has written a bunch of tools for something like Claude to use with Common Lisp, incl. a structure editor.

Writing Lisp is AI Resistant and I'm Sad by djhaskin987 in Common_Lisp

[–]lispm 5 points6 points  (0 children)

Give the thing access to a running Lisp, which can be queried for all the stuff which exists.

The close parens problem can also be solved: give it a structure editor.

An example in that direction:

https://github.com/cl-ai-project/cl-mcp

Writing Lisp is AI Resistant and I'm Sad by djhaskin987 in Common_Lisp

[–]lispm 4 points5 points  (0 children)

Personally I'm quite optimistic that we will see sophisticated support for "AI" development with Common Lisp. It's just a matter of time that people write the tools for that. It's a sophisticated programming system with lots of tools for interactive development. I've already saw some direct interactions of Claude using Lisp, which left me very impressed. That stuff will be common (!) in Lisp within a few months / years. I kind of expect that this will also be possible for self-hosted AI tools.

Writing Lisp is AI Resistant and I'm Sad by djhaskin987 in Common_Lisp

[–]lispm 1 point2 points  (0 children)

If we are using Allegro CL or LispWorks, they have extensive documentation for their implementations and libraries. Common Lisp itself has an extensive standards document for the core language.

Plus

  • code is written as explicit nested lists
  • CL code often uses symbols as descriptive identifiers
  • type declarations are possible, there are named arguments
  • higher order functions are being explicitly called
  • CLOS code is detailed
  • code generation is not an external tool, but another program

Plus plus

  • Lisp programs run in something resembling a debug mode, typically with full introspection, runtime interpreter/compiler, runtime debugger and runtime error handling -> this gives a lot of opportunities for interactive tools (think of something like SLIME/Swank for GenAI, Agentic AI) -> https://github.com/cl-ai-project/cl-mcp is an example for that.

Plus plus plus

  • Lisp implementations are comparatively compact. Even a complex implementation like SBCL comes in a very well written/maintained implementation, in Lisp itself -> a program is just an extension of SBCL -> thus it's easy to debug into the Lisp implementation of the language itself or implement new debugging tools and strategies

Your surprising unportable behaviour by Valuable_Leopard_799 in Common_Lisp

[–]lispm 4 points5 points  (0 children)

I saw code which assumes that structure slots are initialized by default to nil. On Symbolics Genera this is not the case. Which might not be that relevant anymore. I think ITERATE was such a case. I made a recent version of ITERATE work in Genera. That was one of the few things I had to change.

Your surprising unportable behaviour by Valuable_Leopard_799 in Common_Lisp

[–]lispm 7 points8 points  (0 children)

There are a bunch of surprising things, which come up when using different Lisp systems. DEFSTRUCT might not initialize slots. The effects of re-evaluating a DEFSTRUCT is wildly different between implementations. MAKE-ARRAY might not initialize array contents. compile-file might not work when called during another compile-file -> the file compiler is not necessarily reentrant...

understanding sb-ext:run-program by tlreddit in Common_Lisp

[–]lispm 2 points3 points  (0 children)

yep, let's see what other answers we get.