Yes, there are so many weird variants of CSV that makes life difficult. Okay, thanks! It looks like df-select with #:filter is what I need.
@cb1465 has joined the channel
Does Racket have identifier-syntax? For example: (let ()
(define-syntax a (identifier-syntax car))
(list (a '(1 2 3)) a))
; identifier-syntax: undefined;
; cannot reference an identifier before its definition In the book <https://www.scheme.com/tspl4/syntax.html#./syntax:h3|The Scheme Programming Language>, it says that we can define identifier-syntax in terms of make-variable-transformer. I tried it, but seems doesn’t work? (define-syntax identifier-syntax
(lambda (x)
(syntax-case x (set!)
[(_ e)
#'(lambda (x)
(syntax-case x ()
[id (identifier? #'id) #'e]
[(_ x (... ...)) #'(e x (... ...))]))]
[(_ (id exp1) ((set! var val) exp2))
(and (identifier? #'id) (identifier? #'var))
#'(make-variable-transformer
(lambda (x)
(syntax-case x (set!)
[(set! var val) #'exp2]
[(id x (... ...)) #'(exp1 x (... ...))]
[id (identifier? #'id) #'exp1])))])))
(let ()
(define-syntax a (identifier-syntax car))
(list (a '(1 2 3)) a))
; identifier-syntax: undefined;
; cannot reference an identifier before its definition
@chansey97 I believe, make-rename-transformer provides the same functionality.
However, you in your example, (identifier-syntax car) occurs at compile-compile-time, so
Maybe you just need to wrap your definition of identifier-syntax in begin-for-syntax ?
make-rename-transformaer can work. Thanks. (let ()
(define-syntax a (make-rename-transformer #'car))
(list (a '(1 2 3)) a))
I just copy-pasted identifier-syntax from the book and noticed that if I comment out the last expression i.e. (let () ...), Racket does not report an error. So I think the definition of identifier-syntax ought to be correct (?) in Racket. But I don’t understand why it reports identifier-syntax: undefined .
#lang racket
(begin-for-syntax
(require (for-syntax racket/base))
(define-syntax identifier-syntax
(lambda (x)
(syntax-case x (set!)
[(_ e)
#'(lambda (x)
(syntax-case x ()
[id (identifier? #'id) #'e]
[(_ x (... ...)) #'(e x (... ...))]))]
[(_ (id exp1) ((set! var val) exp2))
(and (identifier? #'id) (identifier? #'var))
#'(make-variable-transformer
(lambda (x)
(syntax-case x (set!)
[(set! var val) #'exp2]
[(id x (... ...)) #'(exp1 x (... ...))]
[id (identifier? #'id) #'exp1])))]))))
(let ()
(define-syntax a (identifier-syntax car))
(list (a '(1 2 3)) a))
The problem is that (define-syntax identifier-syntax ...) defines identifier-syntax at phase 1.
In (define-syntax a (identifier-syntax car)) it is used at phase 2.
This gives the unknown identifier error.
Very thanks! @soegaard2 Scheme seems no this problem (I tried in Chez), both in REPL.
The phases work slightly different. If you are interested in the motivation behind Racket’s system, read Flatt’s paper: http://www.cs.utah.edu/plt/publications/macromod.pdf
Thanks!
This paper explains the Scheme way: https://www.semanticscholar.org/paper/Implicit-phasing-for-R6RS-libraries-Ghuloum-Dybvig/c813548d62e3e460ab772b57a006f7cbf329fc1e
Add: The Racket equivalent of Scheme identifier-syntax ought to be make-set!-transformer and make-rename-transformer.