News for hackers. Stuff that matters.
Re:Designing a Language Without a Parser by lispm on Wednesday July 05, 2023 @12:03PM (#36602357)
In Common Lisp the identifiers in package Common Lisp are not allowed to be redefined.
Re:Designing a Language Without a Parser by Zambyte on Wednesday July 05, 2023 @01:55PM (#36604277)
It may be semantically invalid in Common Lisp, but it is syntactically valid in Lisp (as seen by observing different dialects).
Re:Designing a Language Without a Parser by lispm on Wednesday July 05, 2023 @02:01PM (#36604385)
The term "Lisp" is undefined. Common Lisp is an actual standard for a programming language with a specification. Its core symbols are reserved identifiers.

Anyway, if you would be allowed to reimplement a built-in operator, then from then on you would be using the new operator and you would be limited to its syntax.

Common Lisp OTOH provides namespaces (called "package") and there is a pre-defined namespace "COMMON-LISP" for the core language.

Re:Designing a Language Without a Parser by Zambyte on Wednesday July 05, 2023 @02:32PM (#36604931)
> The term "Lisp" is undefined

This hasn't been a problem in this thread thus far, but to be explicit, this seems like a good definition: https://en.wikipedia.org/wiki/Lisp_%28programming_language%2...

Given that definition, we can see that there are many actual standards for programming languages with specifications under the name "Lisp". Scheme - as was mentioned in this thread, is one such standard, along with Common Lisp.

> Anyway, if you would be allowed to reimplement a built-in operator, then from then on you would be using the new operator and you would be limited to its syntax.

I think you're arguing the merits of doing something like redefining define here, which is not the subject of this comment chain. Of course such behavior is questionable at best. The comment chain is discussing if such a thing would be valid in Lisp - and, in some dialects (such as Scheme) it is.

Scheme also has a feature called "libraries" which makes such behavior more feasible, as you could still have access to the shadowed primitive. Consider:

gosh[r7rs.user]$ (import (prefix (scheme base) base:))

gosh[r7rs.user]$ (define (define x) 5)

define

gosh[r7rs.user]$ (base:define x (+ (define define) (define define)))

x

gosh[r7rs.user]$ x

10

Re:Designing a Language Without a Parser by lispm on Wednesday July 05, 2023 @02:52PM (#36605289)
> Scheme - as was mentioned in this thread, is one such standard, along with Common Lisp.

Then see the Scheme standards. They include a syntax definition.

> The comment chain is discussing if such a thing would be valid in Lisp - and, in some dialects (such as Scheme) it is.

Lisp is not a defined language, thus you can assume anything.

My point is: Lisp dialects have syntax. This syntax is usually defined on top of s-expressions. S-expressions also have a syntax, but this syntax usually (there are exceptions) describes only data types and not the actual programming language.

Example: The LET operator in various Lisp dialects there have a specific syntax. This syntax is not the syntax of simple function calls like (operator arg0 ... args).

R7RS small defines this syntax (and also calls it syntax):

  (let ⟨bindings⟩ ⟨body⟩)
  (let ⟨variable⟩ (⟨binding spec⟩*) ⟨tail body⟩)

  ⟨Bindings⟩ has the form ((⟨variable1⟩ ⟨init1⟩) ...)
If you write let forms which don't use this syntax, then they are not valid R7RS Scheme let forms, even though they are valid s-expressions.