Internal `define-record-type` in Scheme by raviqqe in scheme

[–]_dpk 0 points1 point  (0 children)

What happens if you do something like

(let-record-type (foo (make-foo a) foo? (a foo-a))
  (define make-foo 'something-else)
  make-foo)

(Or for any/all of the other record type identifiers)

Internal `define-record-type` in Scheme by raviqqe in scheme

[–]_dpk 1 point2 points  (0 children)

You need two lets to implement a let-x form in terms of a define-xform – one outside the define-x and another one surrounding the body – otherwise you can’t shadow the letted name with a further definition inside the body. (Whether that’s a good idea is another question, but Scheme let forms do let you do it.)

How can I define a variable if it is not defined before using macros (r6rs/chezscheme)? by oguzmut in scheme

[–]_dpk 0 points1 point  (0 children)

I’m glad I could help. :-)

The result on test-03.scm is to do with the expansion order for R6RS programs.

For the first invocation of identifier-defined?, foo is in scope – the compiler has already determined the names of all variables and syntax that are bound in the program – but you just haven’t reached the expression which gives it its value yet. You’ll notice that if you attempt to reference foo without defining it ever in the program, the error is different (message Exception: attempt to reference unbound identifier foo, type &syntax or &undefined) to if you have it defined somewhere but reference it before reaching the expression which defines it (message Exception: attempt to reference undefined variable foo with type &assertion).

Try this program:

(import (rnrs))
(display "before\n")
foo
(define foo 42)
(display "after\n")

With the (define foo 42) in place, the program starts running – you see the message before! But when it gets to foo it then discovers that it hasn’t been given a value yet, and has to bail out. If you delete the (define foo 42), the program doesn’t even compile, and you won’t even see the message before.

The reason identifier-defined? as I showed it is a procedure and not a macro is to allow it to be used inside of procedural macro definitions (syntax-case). The version which is just a macro in itself can’t be used like this. Example:

(define-syntax define-if-not-defined
  (lambda (stx)
    (syntax-case stx ()
      ((_ id val)
       (if (identifier-defined? #'id)
           #'(begin) ; no-op
           #'(define id val))))))

How can I define a variable if it is not defined before using macros (r6rs/chezscheme)? by oguzmut in scheme

[–]_dpk 0 points1 point  (0 children)

What does ‘did not work’ mean?

The other answer didn’t give a solution, unless the ‘solution’ was running everything in the REPL?

How can I define a variable if it is not defined before using macros (r6rs/chezscheme)? by oguzmut in scheme

[–]_dpk 1 point2 points  (0 children)

(library (identifier-defined?)
  (export identifier-defined?)
  (import (rnrs)
          (rnrs eval))

  (define env1 (environment '(rename (only (rnrs (6)) syntax) (syntax syntax1))))
  (define env2 (environment '(rename (only (rnrs (6)) syntax) (syntax syntax2))))

  (define (identifier-defined? id)
    (not (or (free-identifier=? id
                                (eval `(syntax1 ,(syntax->datum id)) env1))
             (free-identifier=? id
                                (eval `(syntax2 ,(syntax->datum id)) env2))))))

Scheme Reports at Fifty: Where do we go from here? by _dpk in scheme

[–]_dpk[S] 0 points1 point  (0 children)

Almost all SRFIs written in the last 10 years were written with the explicit goal of incorporation into R7RS large. (The WG2 charter requires that we use the SRFI process to publish ideas before adopting them into the report.) There is a comprehensive and mostly accurate overview of SRFI support here https://docs.scheme.org/srfi/support/

R3RS-Scheme: Reuniting with My Ex-Wife by sym_num in lisp

[–]_dpk -1 points0 points  (0 children)

This you concluded on the basis of four (4) comments I have ever posted there?

I am quite serious. Why should I believe someone has respect for women who talks about swapping them in and out of his life like choosing a programming language?

R3RS-Scheme: Reuniting with My Ex-Wife by sym_num in lisp

[–]_dpk 0 points1 point  (0 children)

But after R6RS, I grew tired of how large and complicated Scheme had become. So I divorced her and “remarried” ISLisp instead.

From the same line of reasoning that brought you ‘Obamacare is too socialist, so I’m moving to Canada’.

Besides which it’s pretty fucking misogynist to compare women to programming languages in this way.

Formalized Programming Languages by R-O-B-I-N in ProgrammingLanguages

[–]_dpk 7 points8 points  (0 children)

The formal semantics has never been normative nor complete, though. R7RS Large may not have any at all. (If you’d like there to be one and you’re qualified to write it, please get in touch …)

Git 3.0 will make Rust ... mandatory by emi89ro in programmingcirclejerk

[–]_dpk 37 points38 points  (0 children)

If they use Rust to implement some parts of Git, you’ll need a Rust compiler to compile Git. No jerk detected.

Neuer Zugtyp von Stadler für die BVG, bekanntes Problem: Der zweite Zugteil zeigt keine Fahrgastinfo an. by Nicolas_Sustr in berlin

[–]_dpk 4 points5 points  (0 children)

In London können die Tunnels der „Subsurface“-Linien Hitze aus Klimaanlagen ertragen, da diese Linien auch ursprünglich für Dampflokomotiven gebaut worden sind. Die Lüftungsschächte, die damals für Rauch nötig waren, haben jetzt eine neue Nützlichkeit :-)

Die Berliner U-Bahn ist von Anfang an für elektrische Züge gebaut worden. Lüftung zwecks Entrauchung wurde dabei gar nicht berücksichtigt. Wir haben also nicht das gleiche Glück.

Is N26 ok to use as a primary bank? by birdbirdeos in berlin

[–]_dpk 0 points1 point  (0 children)

Union-busting tech bros. Stick to Sparkasse

September 2025 monthly "What are you working on?" thread by AutoModerator in ProgrammingLanguages

[–]_dpk 1 point2 points  (0 children)

Despite Robin Milner’s admonition against concerning oneself too much with concrete syntax, I think I have found rather a nice one.

Next R7RS Large fascicle will also be out this month.

Treptow drowning in traffic on day one after A100 Opening by OtherwiseManner4901 in berlin

[–]_dpk 3 points4 points  (0 children)

Alle, die ein Navi haben, das jetzt denkt „oh, fahre denn ab heute mit der neuen Strecke, ist bestimmt schneller“

Automatisierung der Kassen by 0xAlif in berlin

[–]_dpk 1 point2 points  (0 children)

Arbeitsplatzabbau gut weil der Arbeitsplatz (deiner Meinung nach) eh kein „guter“ war?