[racket-users] Choosing when to call an indenter

2017-08-12 Thread Sam Waxman
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

[racket-users] Running a program in multiple languages at once

2017-08-12 Thread Sam Waxman
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

Re: [racket-users] Running a program in multiple languages at once

2017-08-17 Thread Sam Waxman
gt; 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 12, 2017 at 7:4

[racket-users] Raising multiple nonfatal errors without stopping evaluation

2017-08-17 Thread Sam Waxman
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

[racket-users] Catching duplicate identifiers.

2017-07-17 Thread Sam Waxman
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)

Re: [racket-users] Error when running raco pkg install

2017-07-17 Thread Sam Waxman
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: > > Hello, &g

[racket-users] Getting the phases right on recursive macros/using ... at runtime in syntax-case

2017-07-18 Thread Sam Waxman
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

Re: [racket-users] Catching duplicate identifiers.

2017-07-18 Thread Sam Waxman
vorite-numbers '(1 2 3)) > > > > (define (duplicate-exists? n) > >   (member n my-favorite-numbers)) > > > > (duplicate-exists? 3) > > (duplicate-exists? 4) > > > > > > > > > > > > > On Jul 17, 2017, at 3:43 AM, Sam Wa

[racket-users] Positional arguments in syntax classes

2017-07-24 Thread Sam Waxman
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

Re: [racket-users] Positional arguments in syntax classes

2017-07-24 Thread Sam Waxman
ed 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 2]) 1) in: (my-let ([x 2]) 1) On Monday, July 24, 2017 at 1:19:06 PM UTC-4, Alex Knauth wrote: &

Re: [racket-users] Custom reader that's a strict subset of racket

2017-06-29 Thread Sam Waxman
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, Jun 2

Re: [racket-users] Testing #langs

2017-06-29 Thread Sam Waxman
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 <cleme...@brinckerhoff.org> wrote: > > > >> > >> On Jun 29, 2017, at 08:30, Sam Waxman &

[racket-users] Is there a way to check whether syntax is an expression or a define statement?

2017-06-29 Thread Sam Waxman
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

Re: [racket-users] Is there a way to check whether syntax is an expression or a define statement?

2017-06-29 Thread Sam Waxman
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 <samw...@gmail.com> wrote: > Hey all, > > > > I'm writing a #lang and am trying to raise my own errors instead of having > racket throw any errors

[racket-users] Testing #langs

2017-06-29 Thread Sam Waxman
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

Re: [racket-users] Is there a way to check whether syntax is an expression or a define statement?

2017-06-29 Thread Sam Waxman
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 into a

[racket-users] Catching syntax errors

2017-06-30 Thread Sam Waxman
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

[racket-users] Defining things in two phases at once

2017-07-03 Thread Sam Waxman
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

[racket-users] un-prefix-out provide macro

2017-07-03 Thread Sam Waxman
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

[racket-users] Readers and Namespaces

2017-08-17 Thread Sam Waxman
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

[racket-users] Can a macro "return" a macro without expanding it?

2017-08-18 Thread Sam Waxman
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

[racket-users] Can a macro "return" a macro without expanding it?

2017-08-18 Thread Sam Waxman
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

Re: [racket-users] Re: Readers and Namespaces

2017-08-17 Thread Sam Waxman
On Friday, August 18, 2017 at 1:11:16 AM UTC-4, Alexis King wrote: > > On Aug 17, 2017, at 21:52, Sam Waxman <samwax...@gmail.com> wrote: > > > > On a related note, I've read that read-syntax is supposed to return a > > syntax-object whose lexical context is

Re: [racket-users] Can a macro "return" a macro without expanding it?

2017-08-18 Thread Sam Waxman
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 <samw...@gmail.com> 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 <sam

Re: [racket-users] Can a macro "return" a macro without expanding it?

2017-08-18 Thread Sam Waxman
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 <samwax...@gmail.com> wrote: > > > > If I have code like this, > > > > (define-syntax-rule (identity x) > > x) > >

[racket-users] Re: Readers and Namespaces

2017-08-17 Thread Sam Waxman
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" in one file

[racket-users] Is there a (#%variable-value ...) macro like there are for #%datum, #%app, etc?

2017-06-20 Thread Sam Waxman
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

Re: [racket-users] Expanding a macro into multiple syntax objects (Defining two things with one macro)

2017-06-22 Thread Sam Waxman
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 <samw...@gmail.com> wrote: > Hello, > > > > It's sim

[racket-users] Expanding a macro into multiple syntax objects (Defining two things with one macro)

2017-06-22 Thread Sam Waxman
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

[racket-users] Change how to print builtins

2017-06-22 Thread Sam Waxman
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 +

[racket-users] Suppress print lines from required modules

2017-08-27 Thread Sam Waxman
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

[racket-users] Turning off the sharing check for printing

2017-08-31 Thread Sam Waxman
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

[racket-users] Mapping over pattern variables

2017-09-01 Thread Sam Waxman
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