Questions tagged [hygiene]

Questions should be tagged with the hygiene tag when they involve both macro expansions and name collisions, which means that only specific programming languages using macros are concerned (like C, Lisp, Scheme, etc.).

See Hygienic Macros on Wikipedia.

42 questions
1
vote
2 answers

Why dirty injection is necessary even for code within template's scope?

Please consider the following: import options template tpl[T](a: untyped) : Option[T] = var b {.inject.}: T = 4 a none(int) discard tpl[int]: echo b This builds and runs and results in output: 4 But, if you remove the {.inject.}…
v.oddou
  • 6,476
  • 3
  • 32
  • 63
1
vote
1 answer

Dynamically prefix macro names with a variadic macro

Background I've utilized a set of preprocessor macros from another question that allows me to prefix symbol names (enums, function names, struct names, etc) in my source, i.e.: #include #define VARIABLE 3 #define PASTER(x,y) x ## _ ##…
Cloud
  • 18,753
  • 15
  • 79
  • 153
1
vote
1 answer

How to make just part of a macro hygienic

I'd like to have a version of lambda, called lambda-r, from within which you can return. An example: (+ ((lambda-r () (return 1) 2)) 5) This would give the value 6. Although you might expect the value to be 7, it's 6 because 1 is returned…
Cam
  • 14,930
  • 16
  • 77
  • 128
1
vote
1 answer

Weird hygiene in macros

Suppose I have this macro definition in a module: module Example export @example_macro macro example_macro(a) quote local r = RemoteRef() put!(r, $(esc(a))) remotecall_fetch(2, (r) -> fetch(r), r) end end end And…
Vladimir Matveev
  • 120,085
  • 34
  • 287
  • 296
0
votes
0 answers

Getting error while running mvn clean install in hygieia/API

While running mvn clean install in hygieia/API [ERROR] Errors: [ERROR] MonitorProxyConfigTest.testProxy_PROXY_DIRECT:122->assertAuthenticator:370 » InaccessibleObject Unable to make field private static volatile java.net.Authenticator…
0
votes
3 answers

Elixir var! ... How to read a variable from caller's scope

Sorry if this has already been asked. Searching the forum for var! gives me all the posts with word var. Made it hard to narrow it down. Struggling with writing a macro that reads a variable out of the caller's context and returns it from a…
0
votes
1 answer

How to insert literal identifier from input pattern as symbol in syntax-rules macro

I have code like this: (define-syntax macron (syntax-rules () ((_ name) (lambda (x) (eval (cons 'name x) (interaction-environment)))))) (define x (map (macron lambda) '(((x) (display x)) ((a b) (+ a b))))) (let…
jcubic
  • 61,973
  • 54
  • 229
  • 402
0
votes
1 answer

How to turn off macro hygiene?

I'm trying to make a macro that pastes in boilerplate code and I would like to use the variables it pastes in afterwards. Rust's macro hygiene is preventing this; how do I turn this off? I understand that there are ways to work around it, by passing…
0
votes
1 answer

How can I extract hygiene ratings from Zomato?

I'm working on a project where I'd look to analyze the hygiene ratings of the restaurants listed on Zomato in Delhi. I was able to get the restaurant details using the Zomato /search API but the API does not provide the hygiene rating of the…
Aastha Jha
  • 153
  • 1
  • 2
  • 14
0
votes
1 answer

Why is next not gensymed?

Here x is gensymned because some expression passed to and can have x in it and to avoid that conflict. Then why is next not gensymed? Couldn't next lead to variable capture? (defmacro and ([] true) ([x] x) ([x & next] `(let [and# ~x] …
John Doe
  • 2,225
  • 6
  • 16
  • 44
0
votes
3 answers

Writing myletstar macro (hygiene) in Scheme

I am trying to re-write let* hygiene macro, I have it as normal macro and I would like to have it as hygiene macro if it's possible. I don't have too much experience with this macro types. So I would really appreciate help. Also my another…
dyouteotyi
  • 27
  • 4
0
votes
0 answers

How to flag bad code

I want to flag bad code (as advised by the GSL), what would be the best way to do it? For example given the function foo below (not the best example i could fix this easily myself). void foo(std::string& s){ std::cout << s; } Three ideas did…
user1235183
  • 3,002
  • 1
  • 27
  • 66
1 2
3