Skip to content

Token-pasting operator (spec clarification) #1008

Open
@loren-osborn

Description

@loren-osborn

The presence or absence of the # and ## operators are underspecified

Currently, the spec states:

Open Shading Language compilers support the full complement of C/C++ preprocessing
directives, including:

But makes no mention of the stringizing # or token-pasting ## preprocessor operators.

While I am not a big fan of advanced use of C-style macros, I have seen them used, without reducing code quality or readability, when C++ style templates were inadequate for the task, (or, as here, not available) but this usually requires the token pasting operator to accomplish much useful.

While I would prefer C++ style templates, as they are typically clearer and usually more flexible, they require more complexity and overhead than are warranted in OSL.

I believe that the token pasting operator would barely alter the spec, (which is underspecified in this particular) and shouldn’t be difficult to add to the compiler, nor make runtime compilation less efficient.

Expected behavior:

When describing the preprocessor, the spec should state if the two preprocessor operators are supported, or in what OSL version they were first supported.

(The compiler also needs to be kept in sync with this verbiage)

Actual behavior:

No mention of the two preprocessor operators is made.

Steps to Reproduce

  1. Read section 3.5 of the OSL specification.

Versions

  • OSL branch/version: 1.10 release
  • OS: n/a
  • C++ compiler: n/a
  • LLVM version: n/a
  • OIIO version: n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions