23. Features
23.1 Typed library adapters
CS-FEATURE-001. A feature is a typed compile-time adapter over existing library APIs. Its declarations reside in ordinary .ds source or referenced declarations/metadata. A feature is not a runtime object, an unrestricted macro, a new type system or a compiler plugin. Ordinary application classes and direct library calls remain the foundation of application code.
A feature declares operation vocabulary and explicit effects. The declaration below describes a query adapter whose methods must be available to ordinary binding:
feature query
target Global.System.Linq.IQueryable <of T>
operation where(predicate as captured expression)
calls Global.System.Linq.Queryable.Where
sets current from result
end operation
end feature
This declaration defines the adapter vocabulary; it does not add a new global core where statement or a database provider.
CS-FEATURE-002. Operation effects include calling an adapter/library member, creating a current value, replacing current from its result, returning its result and declaring a typed runtime-bound symbol. Nested operations introduce vocabulary local to their containing operation. Ordinary CLR overload resolution, inference and return types provide typing; there is no parallel feature type system.
23.2 Context and captured expressions
CS-FEATURE-003. Leading-dot access uses the current contextual value. When an operation replaces current with a result of a different type, subsequent dot access uses that resulting type. Multiple simultaneously active subjects require named contexts rather than an ambiguous dot receiver.
CS-FEATURE-004. A captured expression is type-checked in the adapter's expected context and represented as the delegate/expression form required by its ordinary API. Runtime-bound symbols introduced by an operation have their declared/inferred type and obtain their value from the adapter/environment; they are not compile-time runtime values.
Blocks passed through operations contain ordinary DirectSharp. Features may produce expression values and nest through normal value semantics. They do not redefine the meaning of return, contracts, async calls or lexical scopes.
23.3 Catalog and boundary
CS-FEATURE-005. Features are discovered deterministically from current source and known references. No project/file activation list is required. An unused available feature must not force its underlying library into the project. Using an unavailable feature/library produces a diagnostic; compilation never silently adds a package/reference.
CS-FEATURE-006. Feature names have no special alias mechanism. Conflicting available language-visible feature names produce an ambiguity error identifying definitions. There is no reference-order precedence or hidden shadowing.
A feature may adapt calls, current values, captured expressions, ordinary callable blocks and runtime symbols. It may not generate arbitrary classes/members, alter existing types, rewrite arbitrary ASTs or change core semantics. Source transformation belongs to wrappers or separate tooling. Domain-specific logging, validation and repository methods do not become language keywords simply because they can be adapted.
Specification contents · Previous: 22. Extensions · Next: 24. Wrappers