You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 4262 Reporter: nogin Assigned to: ertai Status: closed (set by @xavierleroy on 2010-04-29T12:18:08Z) Resolution: fixed Priority: normal Severity: minor Version: 3.10+dev Fixed in version: 3.10+dev Category: -for Camlp4 use https://github.com/ocaml/camlp4/issues Monitored by: nogin
Bug description
As I wrote to the Caml list yesterday, I have noticed that the Camlp4MacroParser in 3.10.0+beta has an unfortunate problem - when processing an "IFDEF" (or "IFNDEF") directive, it will execute the "DEFINE"s in both branches, regardless of whether the test is true or not (this was caused by the fact that the DEFINE directives would be executed eagerly at parse-time).
Attached is a corrected and improved version of the Camlp4MacroParser:
Fixes the above problem; now the execution of the "DEFINE" directives inside IFDEF/IFNDEF is correct.
Adds support for "local" definitions
DEFINE = IN
This is particularly useful for things like
DEFINE body =
...
IN
IFDEF DEBUG
let result = body in
print_debug result;
result
ELSE
body
Adds an ability to omit the "ELSE" part of the IFDEF/IFNDEF expressions (the "ELSE" branch is then taken to default to unit expression "()").
Adds an ability to use the macro argument as a pattern (provided the argument is a sufficiently simple expression)
Adds a special macro "NOTHING" that can be used to "wipe out" unneeded function arguments. This is useful to be able to generate functions of different arity using the same macro.
Original bug ID: 4262
Reporter: nogin
Assigned to: ertai
Status: closed (set by @xavierleroy on 2010-04-29T12:18:08Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.10+dev
Fixed in version: 3.10+dev
Category: -for Camlp4 use https://github.com/ocaml/camlp4/issues
Monitored by: nogin
Bug description
As I wrote to the Caml list yesterday, I have noticed that the Camlp4MacroParser in 3.10.0+beta has an unfortunate problem - when processing an "IFDEF" (or "IFNDEF") directive, it will execute the "DEFINE"s in both branches, regardless of whether the test is true or not (this was caused by the fact that the DEFINE directives would be executed eagerly at parse-time).
Attached is a corrected and improved version of the Camlp4MacroParser:
Fixes the above problem; now the execution of the "DEFINE" directives inside IFDEF/IFNDEF is correct.
Adds support for "local" definitions
DEFINE = IN
This is particularly useful for things like
DEFINE body =
...
IN
IFDEF DEBUG
let result = body in
print_debug result;
result
ELSE
body
Adds an ability to omit the "ELSE" part of the IFDEF/IFNDEF expressions (the "ELSE" branch is then taken to default to unit expression "()").
Adds an ability to use the macro argument as a pattern (provided the argument is a sufficiently simple expression)
Adds a special macro "NOTHING" that can be used to "wipe out" unneeded function arguments. This is useful to be able to generate functions of different arity using the same macro.
The improved Camlp4MacroParser.ml is attached.
Aleksey
File attachments
The text was updated successfully, but these errors were encountered: