Lets say I have a macro
(define-syntax (macro stx)
(syntax-parse stx
[(_ (var1 ...) (var 2 ...))
#'(begin
(begin
(do-something (#freeze var1) var2)
...)
...)]))
and I want to iterate first over var2, and then over var1. So if I type
(macro (1 2
I wrote a custom printer, and the printer itself has side-effects. As such, I
need to be absolutely certain that when I print something, the print function
only gets called once.
When checking my test cases, things were failing, and then I found out that
Racket calls the print function multiple
Let's say I have a module that looks like
(module a racket
(provide result)
(print "Annoying print line!")
(define result 2))
and I'd like the value of result in another module, so in another module, I
write
(require a)
or
(dynamic-require ''a 'result)
In both cases, I get the value
On Friday, August 18, 2017 at 10:14:10 AM UTC-4, Matthias Felleisen wrote:
> On Aug 18, 2017, at 9:44 AM, Sam Waxman wrote:
>
> On Friday, August 18, 2017 at 9:31:33 AM UTC-4, Matthias Felleisen wrote:
> On Aug 18, 2017, at 5:28 AM, Sam Waxman wrote:
>
> If I have code like
On Friday, August 18, 2017 at 9:31:33 AM UTC-4, Matthias Felleisen wrote:
> > On Aug 18, 2017, at 5:28 AM, Sam Waxman wrote:
> >
> > If I have code like this,
> >
> > (define-syntax-rule (identity x)
> > x)
> >
> > ((identity identity) 1)
>
If I have code like this,
(define-syntax-rule (identity x)
x)
((identity identity) 1)
At phase 1, the (identity identity) will get transformed into identity. As
macros expand outside in, however, this won't turn into (identity 1) like a
function would, it will try expanding the identity mac
If I have code like this,
(define-syntax-rule (identity x)
--
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to racket-users+unsubscr...@googlegroups.com.
For more
On Friday, August 18, 2017 at 1:11:16 AM UTC-4, Alexis King wrote:
> > On Aug 17, 2017, at 21:52, Sam Waxman wrote:
> >
> > On a related note, I've read that read-syntax is supposed to return a
> > syntax-object whose lexical context is stripped. Why is that? Doesn&
On Friday, August 18, 2017 at 12:47:45 AM UTC-4, Sam Waxman wrote:
> I've recently run into some ambiguous identifier errors while writing a
> reader, and I'm not sure how to solve them.
>
> The situation is as follows:
>
> I've created a version of "let&qu
I've recently run into some ambiguous identifier errors while writing a reader,
and I'm not sure how to solve them.
The situation is as follows:
I've created a version of "let" in one file. I'd like my reader to call it
whenever the user types something like
a = 3
body ...
which should be rea
Hey all,
One of the things that confuses me most in Racket is good error handling, and
the continuations that are involved.
Is it possible to raise an error, have the user see it, but then still go on
running the code? I can currently catch an error, display it as a string/other
formats and th
ram once for each
> language
>
>
> Something like `raco mystery-lang -L lang1 -L lang2 -L lang3 file.txt`
>
>
>
>
> In case you need an example raco-command:
> https://github.com/AlexKnauth/syntax-sloc/blob/master/syntax-sloc/info.rkt
>
>
>
> On Sat, Aug
Hello,
Let's say I have a program the user entered that just looks like
1 + 2
and I have three different #langs, all with different parsers and different
notions of addition, for which this is a valid program. I'm looking to make it
so that this program outputs the following:
"Output for la
Hello,
I just built an indenter for a #lang I wrote, and placed it into the get-info
function. It seems that by default, Racket will only call the indenter if you
tell it to (by hitting tab or control I) or when you hit enter. In the latter
case, it will only indent the line you're on after you
body ... last-body)]))
>
>
> You might want to look at `expr/c` for an example of a syntax class that
> takes arguments:
> http://docs.racket-lang.org/syntax/Library_Syntax_Classes_and_Literal_Sets.html?q=~expr%2Fc#%28def._%28%28lib._syntax%2Fparse..rkt%29._expr%2Fc%29%29
&g
When I try writing it the original way but with the
updated my-id version, I get
id:my-id: expected 1 positional argument; got 0 positional arguments in:
id:my-id
and when I write it with the parentheses like I did in the last example I get
my-let: expected more terms at: () within: (my-let ([x
Probably a silly question but I can't figure out how to get this working.
I want to have a syntax class that I can pass arguments into. So,
(define-syntax-class (my-syn-class argument)
...
)
(syntax-parse #'some-syntax
[(_ x:**)])
In place of ** what do I write to pass the argument
>
>
> (define my-favorite-numbers '(1 2 3))
>
>
>
> (define (duplicate-exists? n)
>
> (member n my-favorite-numbers))
>
>
>
> (duplicate-exists? 3)
>
> (duplicate-exists? 4)
>
>
>
>
>
>
>
>
>
>
>
Hello,
Suppose I'd like a type-checking macro that looks something like this:
(define-syntax (type-check stx)
(syntax-case stx ()
[(_ (+ x y)) (if (and (number? (type-check #'x))
(number? (type-check #'y)))
#'Number #'(error "bad types!"))
ows support symbolic links, only an
> administrator can create them. Package authors need to take that into
> account and not include symbolic links in a package if it's meant to
> be installed on Windows.
>
> At Mon, 17 Jul 2017 09:18:55 -0700 (PDT), Sam Waxman wrote:
> > Hell
Hello,
I'm working on my Windows 10 machine, trying to install a package using the
raco command. Specifically, I typed in
raco pkg install racketscript
and also tried installing the package through doctor racket. Both methods yield
the following output:
C:\Users\Sam>raco pkg install racketscr
Hello,
In the regular #racket, the following program
(define a 1)
(define a 2)
will result in a syntax error letting you know that you have a duplicate
identifier. I would like to make my own define that throws a custom error
message in this case. I.e.
(define-syntax (my-define stx)
(syntax
Hello,
I have a function, foo, that I define in a file, and then use later on in that
file in multiple other functions. In some of the functions, I need foo at phase
0. In others, I need it at phase 1.
Is there a way to define foo in both phases at once, or do you need to copy and
paste the de
Hello,
I really need a provide macro with the following style
(provide
(un-prefix-out "..Some-file/modulepath" number))
Where the number will determine how many characters to delete from each
identifier before exporting them.
I.e., if we were to require racket as
(require
(prefix-in rack-
Hello,
I'm trying to test whether or not certain programs result in syntax errors. For
example the program
#lang racket
a
will result in an unbound identifier error, even before runtime (you'll see the
little error message at the bottom because it errored in phase 1).
I know how to catch runt
On Thursday, June 29, 2017 at 11:17:12 PM UTC-4, Philip McGrath wrote:
> I think you might be able to leave the reader as-is and just re-define
> #%datum to reject whatever kinds of literal data you don't want to allow.
>
>
>
> -Philip
>
>
>
> On Thu,
Hello,
I'm building a #lang, and I don't want it to have a few things like complex
numbers, or vectors. Other than the things I don't want, the reader would be
identical to racket's. Is there an easy way to "turn off" the things I don't
want, so to speak, and take Racket's reader and delete the
On Thursday, June 29, 2017 at 11:47:00 AM UTC-4, Matthew Flatt wrote:
> At Thu, 29 Jun 2017 08:10:25 -0700 (PDT), Sam Waxman wrote:
> > One of my constructs, (func name(args) body), defines a function that's
> > able
> > to be called afterwards, and it desugars in
On Thursday, June 29, 2017 at 11:49:49 AM UTC-4, 'John Clements' via
users-redirect wrote:
> Oops forgot to cc: list
>
> > On Jun 29, 2017, at 08:49, John Clements wrote:
> >
> >>
> >> On Jun 29, 2017, at 08:30, Sam Waxman wrote:
> >>
&
On Thursday, June 29, 2017 at 11:22:38 AM UTC-4, David K. Storrs wrote:
> On Thu, Jun 29, 2017 at 11:10 AM, Sam Waxman wrote:
> Hey all,
>
>
>
> I'm writing a #lang and am trying to raise my own errors instead of having
> racket throw any errors of its own.
>
Hey all,
I've been running into a lot of major roadblocks when it comes to writing good
tests for some #langs that I've made, for a number of reasons.
Ideally, I want a function called
(check-eq-program? "program1" "program2")
That will run each program in a fresh module of my #lang, check what
Hey all,
I'm writing a #lang and am trying to raise my own errors instead of having
racket throw any errors of its own.
One of my constructs, (func name(args) body), defines a function that's able to
be called afterwards, and it desugars into a pretty regular define statement.
As a result, I c
Hello,
I was having trouble figuring out how to get racket to print values however I
wanted. In particular, I was hoping to make exact nums print as decimals and
true print as true (and not #t or #true). It would also be nice if I could
custom print procedures so that + printed as plain old + o
(define larry (+ 1 moe)))
> (list larry curly moe))
>
> '(2 0 1)
>
> - Sam Caldwell
>
> [1] http://docs.racket-lang.org/guide/begin.html
>
>
> On Thu, Jun 22, 2017 at 3:40 PM, Sam Waxman wrote:
> Hello,
>
>
>
> It's simple
Hello,
It's simple enough to write a macro that defines something.
(define-syntax-rule (my-define name binding)
(define name binding))
But what if I would like to define multiple things? I.e.
(define-syntax-rule (my-multiple-define name ... binding ...)
(define name binding) ...)
The abo
Hey all,
I'm trying to write a few #langs in racket, and I've been making use of the
#%datum, #%app, and a few of the other macros that automatically wrap certain
types of expressions. Is there a wrapper like this that works for determining
the values that are bound to variables? (I.e. so that
36 matches
Mail list logo