Skip to main content
Filter by
Sorted by
Tagged with
1 vote
1 answer
112 views

I am trying to make a macro similar to register-groups-bind in the Common Lisp cl-ppcre library. The idea is that you make a regex with groups, and give it a list of variables, statements to execute. ...
Mark Wutka's user avatar
0 votes
1 answer
935 views

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 ...
Oliver's user avatar
  • 11
-1 votes
1 answer
51 views

I know Java does not have pre-processor, but I struggle to find a way to do this. I am looking to create macros to improve code readibility, to specify which of the functions or parameters are for ...
IlluSion's user avatar
-1 votes
1 answer
57 views

I am trying to a make plugin system which will have a header file for all plugins to include. In that header the version of the plugin system is defined in a #define like so: PluginHeader.hpp: #define ...
Yann's user avatar
  • 189
1 vote
1 answer
2k views

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 ...
Manuel Yguel's user avatar
2 votes
2 answers
165 views

I'm experimenting to see how far I can abuse the C preprocessor and I have stumbled across an interesting problem. I have the following macro defines: #define if(x) if (x) #define do { #define ...
agregate's user avatar
  • 163
2 votes
3 answers
280 views

I have a #define with generates a enum class and a corresponding output operator the the generated enum class.(see below) #define ENUM(N, T, N1, V1, N2, V2, N3, V3, N4, V4, N5, V5, N6, V6, N7, V7)\ ...
Rainer's user avatar
  • 51
1 vote
1 answer
1k views

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 ...
mab0189's user avatar
  • 236
1 vote
1 answer
171 views

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 ...
clartaq's user avatar
  • 5,382
-1 votes
1 answer
412 views

I am trying to make my own pattern-matching system in Scheme. To begin I am making a parser for s-expressions that divides them into tokens like this: '(1 2 b (3 4)) => '(number number symbol (...
Caspian Ahlberg's user avatar
0 votes
1 answer
524 views

I am trying to make a logic system using defines macros for implementation of my logger that will expand into nothing when certain toggles are defined. The problem is that when I stack multiple of ...
Christopher Jakubek's user avatar
1 vote
0 answers
357 views

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 ...
Sharky's user avatar
  • 393
0 votes
1 answer
48 views

(define-syntax my-class (syntax-rules () [(my-class <class-name> (<attr> ...) (method (bigger-x other) (> x (other 'x)))) (define (<class-name> &...
user8314628's user avatar
  • 2,072
0 votes
2 answers
150 views

I'm currently learning some r7rs and I am trying to implement a macro 'begin' as following : (begin0 expr0 expr1 ... expr2) With expr being a regular expression (Like (set! x (+ x 1))) And begin0 as ...
Lucas M's user avatar
  • 13
1 vote
1 answer
242 views

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 #...
AC-93's user avatar
  • 85
-1 votes
1 answer
5k views

I am using a define macro to set the path for a module, ie, `define DUT_PATH(CH) dut_top.u_channel_```CH``_mode and using this define macro in a module where we are passing the channel number , ...
Anu's user avatar
  • 1
1 vote
1 answer
227 views

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 ...
Atonic's user avatar
  • 559
1 vote
2 answers
2k views

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 ...
Peter Cerba's user avatar
0 votes
1 answer
38 views

I wrote the following Scheme macro. (define-syntax join (syntax-rules () ((join (var ...) (val ...) ...) '(((var val) ...) ...)))) When I try it (join (a b c) (1 2 3) (...
ceving's user avatar
  • 24.2k
1 vote
1 answer
514 views

I am trying to create my own while-loop in racket using the "define-syntax-rule". I want it to be procedural based, so no helper functions (i.e. just using lambda, let, letrec, etc.). I have this, ...
kmgauthier's user avatar
5 votes
2 answers
525 views

I found myself defining syntax parameters with identical definitions except for their name so I decided to write a macro to make this simpler: (define-syntax (test-case-parameter stx) (syntax-parse ...
Joseph Garvin's user avatar
2 votes
1 answer
661 views

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? ...
Sod Almighty's user avatar
  • 1,856
4 votes
2 answers
99 views

I want to be able to write: (nota E2 82) instead of: (define E2 (network () [sunet <= sine-wave 82] [out = (+ sunet)])) I know I can do this using macros and tried to ...
Theodor Berza's user avatar
0 votes
1 answer
120 views

I don't really understand the arguments and usage of define-syntax within Scheme. For what it's worth, I'm using Petite Chez Cheme. I've looked at a few sources: define-syntax issue in scheme Scheme ...
shane's user avatar
  • 246
2 votes
1 answer
71 views

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 ...
Feng's user avatar
  • 2,930
2 votes
2 answers
635 views

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 ...
dubiousjim's user avatar
  • 4,862
3 votes
1 answer
358 views

I'm trying to write a define-let macro in racket, which "saves" the header of a (let ((var value) ...) ...) , namely just the (var value) ... part, and allows re-using it later on. The code below ...
Suzanne Soy's user avatar
  • 3,295
2 votes
1 answer
2k views

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 ...
Millie Smith's user avatar
  • 4,614
0 votes
1 answer
914 views

I'm pretty new to Objective-C and what I want to do is have define variables in the EntityNameConstants.h file where I store all the Entity Names. And the I will use all the defines in repository for ...
Nikita255's user avatar
7 votes
3 answers
1k views

What's the simplest way to define a capturing macro using define-syntax or define-syntax-rule in Racket? As a concrete example, here's the trivial aif in a CL-style macro system. (defmacro aif (...
Inaimathi's user avatar
  • 14.1k
6 votes
1 answer
430 views

To give a simple example: (define-macro-variable _iota 0) ; define-macro-variable does not really exist (define-syntax (iota stx) (syntax-case stx () ((iota) (let ((i _iota)) (set! ...
Matt's user avatar
  • 22.5k
1 vote
1 answer
880 views

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: ...
Carlos Filipe Costa's user avatar
5 votes
2 answers
947 views

I'm learning about the macro system in Scheme and I thought implementing curried functions would be a good start. This is what I cooked up: (define-syntax function (syntax-rules () ((_ () ...
Aadit M Shah's user avatar
  • 74.5k
0 votes
2 answers
458 views

I'm learning how the macro system in Scheme works and I'm trying to make my code look more JavaScript-y. So I thought I would start with the function macro. This is how I want a function definition to ...
Aadit M Shah's user avatar
  • 74.5k
3 votes
2 answers
486 views

I've just started diving into Racket macros, and am trying to make a terse simple-macro-defining macro. I would like to expand an expression like this: (macro id (param) replacement1 (params ....
twf's user avatar
  • 325
1 vote
1 answer
591 views

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.. ...
eric17859's user avatar
  • 428
1 vote
1 answer
1k views

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-...
kjfletch's user avatar
  • 5,514
6 votes
2 answers
424 views

I've been told that "call/cc" can be used to implement arbitrary control flow constructs so I'm trying to implement all such constructs using "call/cc" but I'm having trouble. Assuming I didn't have "...
N4tur41Myst1c's user avatar
5 votes
1 answer
1k views

I'm working though SICP and wanted to try out some of the examples in guile. I'm trying the stream examples and wanted an implementation for cons-stream, which I got from this StackOverflow question. ...
Tom Carver's user avatar
  • 1,048
5 votes
4 answers
1k views

R5RS gives proposed macro definitions for library forms of syntax: http://schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-10.html#%_sec_7.3 Which also defines letrec, in a very complicated way, ...
Zorf's user avatar
  • 6,474
6 votes
1 answer
223 views

I have been writing Common Lisp macros, so Scheme's R5Rs macros are a bit unnatural to me. I think I got the idea, except that I don't understand how one would use vector patterns in syntax-rules: (...
Jay's user avatar
  • 9,696
5 votes
3 answers
774 views

Can a macro be written in Scheme (with define-syntax, for example) which will take expressions like this: (op a b c d e f g h i j) And yield expressions like this as output? (op (op (op (op (op (op (...
Claudiu's user avatar
  • 231k
10 votes
4 answers
6k views

I've read JRM's Syntax-rules Primer for the Merely Eccentric and it has helped me understand syntax-rules and how it's different from common-lisp's define-macro. syntax-rules is only one way of ...
Kyle Burton's user avatar
  • 27.9k