AcademySoftwareFoundation / AcademySoftwareFoundation/OpenShadingLanguage

Token-pasting operator (spec clarification)

Open
#1,008 2 comments 0 reactions 0 assignees View on GitHub
docs
Dominant language
C++
Stars
2.3k
Forks
414
Avg merge
3d 1h
Merged PRs (30d)
10

Description

### 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

Contributor guide

Open the contributing guide

Research direction

Start with section 3.5 of the OSL specification and then inspect the compiler's preprocessor handling for the `#` and `##` operators. Determine their supported status or first OSL version, document that behavior, and ensure the compiler remains consistent with the specification.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.