Questions tagged [define-syntax]

42 questions
2
votes
1 answer

How to call other macros from a Chicken Scheme macro?

I'm trying to move from Common Lisp to Chicken Scheme, and having plenty of problems. My current problem is this: How can I write a macro (presumably using define-syntax?) that calls other macros? For example, in Common Lisp I could do something…
Sod Almighty
  • 1,768
  • 1
  • 16
  • 29
2
votes
1 answer

Is it possible to use user defined fuctions when expanding macro?

From chicken scheme manual: define-syntax evaluates the procedure in a distinct expansion environment (initially having access to the exported identifiers of the scheme module) Is it possible to inject the user-function to the expansion…
Feng
  • 2,872
  • 3
  • 23
  • 20
2
votes
2 answers

How to control order of Scheme macro expansion?

I'm working with the Racket macro extension syntax-id-rules, that some other Scheme implementations provide under the name identifier-syntax. These let you specify macro expansions that will happen even when the defined identifier isn't in head…
dubiousjim
  • 4,722
  • 1
  • 36
  • 34
2
votes
1 answer

Defining a For Loop in Scheme

Note: This appears to be Gauche Scheme version 0.9.3.3. I cannot seem to wrap my head around these Lisp languages :/. I'm trying to define a for loop syntax in Scheme. I'm not sure if this is doable with a recursive function (I think it is), but at…
Millie Smith
  • 4,536
  • 2
  • 24
  • 60
1
vote
1 answer

Scheme R5RS define-syntax ignored?

Just started learning Scheme. I'm using Dr. Racket as my compiler/interpreter. I need some String functions (string-replace to be exact), so I copied from SRFI 13. When I test it, it shows.. reference to undefined identifier:…
eric17859
  • 418
  • 1
  • 5
  • 17
1
vote
1 answer

Scheme macro expansion: Nesting let-syntax inside define-syntax

I wish to expand (foo x (f n) (f n) (arbitrary) (f n) ...) into (begin (x 'f n) (x 'f n) (arbitrary) (x 'f n) ...) my attempt is: (define-syntax foo (syntax-rules () ((_ l a ...) (let-syntax ((f (syntax-rules () …
kjfletch
  • 5,394
  • 3
  • 32
  • 38
1
vote
1 answer

For C/C++ syntax highlighting in vscode : how to tell vscode that a compile option "-Dxxxx" will be used?

When developing for micro controller, we use a lot of compile-time defines passed to the compiler with the "-Dxxxx" syntax. I would like to configure vscode such that it knows that certain defines will be provided and such that it highlights code…
1
vote
1 answer

How to handle C char* defines in C++

I am porting some C code to C++ right now. The C code is using multiple defines like: #define IPADDRESS "fd9e:21a7:a92c:2323::1" The problem that i have is that when i am calling C functions with the defines that are now in the C++ file i…
mab0189
  • 126
  • 12
1
vote
1 answer

How to increment a Record Field using Scheme define-syntax macro

Given a Chez Scheme record with many numeric fields that are contantly being mutated by small increments and decrements, usually by one, is there a way to write a macro that can mutate a field value by passing it the field? The way I accomplish this…
clartaq
  • 5,320
  • 3
  • 39
  • 49
1
vote
0 answers

Unsequenced function calls: error for a #define

A static code analysis tool shows me that I have an unsequenced function calls for a define. Want to get rid of the warning. It complains that I use Logging() and get_id() (two functions, only one allowed) in the last define. #define MSG_FORMAT(x) "…
Sharky
  • 323
  • 1
  • 3
  • 11
1
vote
1 answer

how to comment values under #ifdef in one place

let's imagine we have a C++ project that should work on several platforms (for example, arm/arm64) and we need to have target-specific values for each of them. Right now we do: #ifdef PLATFORM_ARM #define TIMEOUT_VALUE 0 #define OUR_MAGIC_VALUE…
AC-93
  • 85
  • 1
  • 7
1
vote
1 answer

Provide syntax-rule Racket

How do I provide syntax rules in racket? I have code which is similar to this: (define-syntax SELECT (syntax-rules (FROM WHERE star) [(SELECT colnames FROM relnames) ...] [(SELECT colnames FROM relnames WHERE . expression) …
Atonic
  • 509
  • 1
  • 5
  • 14
1
vote
2 answers

Cannot resolve function-like macro inside conditional compilation block

Consider the following - I want to check with #if #endif whether a token is defined somewhere in the code. I am using a CONCAT(input) macro that should glue the constant and changing parts of the token that I want to check. Unfortunately, the…
1
vote
1 answer

how to create a macro in racket where a list becomes the args of said lambda?

How would I go about in doing a define-syntax-rule that accepts a list as arguments and a list (or a quote, in case it is a single element) as body of a lambda? i would like to do something like: >(define a (lambdarize '(x y z) '(+ x y z))) …
0
votes
1 answer

Can you use #defines like method parameters in HLSL?

In HLSL, is there a way to make defines act like swap-able methods? My use case is creating a method that does fractal brownian noise with a sampling function(x, y). Ideally I would be able to have a parameter that is a method, and just call that…
Oliver
  • 11
  • 2