Skip to content

make proc nimQuery(setting: Setting): RootObj {.magic.} => return a type that depends on the enum #9

Open
@timotheecour

Description

@timotheecour

@Araq ok with following?

proposal

  • deprecate compileOption, querySettingSeq and querySetting (or "soft" deprecate ie recommend the alternative here)
  • introduce
# in compilesettings
proc nimQuery*(setting: Setting): RootObj {.compileTime, magic.}

why RootObj ? because that's what used in iterator fields*[T: tuple|object](x: T): RootObj to allow returning a type that can depend on input argument

example

doAssert nimQuery(nimVerCT) == (1,3,7)
  # I need this in many places, after this we don't need to define new symbols in condsyms anymore since we can test for nimVerCT
  # i had originally introduced it in https://github.com/nim-lang/Nim/pull/14447#issuecomment-633725338 but moved it out of there
doAssert nimQuery(assertions) # can replace `compileOption("assertions")`
doAssert nimQuery(backend) == Backend.js
doAssert nimQuery(arguments) is seq[string]
doAssert Experimental.notnil in nimQuery(experimental)

note

compilesettings stays a "low-level" module in the sense it's usable by low level modules (eg doesn't depend on iterators, dollars etc)

implementation

no particular difficulty

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions