8000 Standard Library Structure (`@use` Directives) · Issue #90 · Mnehmos/mnehmos.nls.lang · GitHub
[go: up one dir, main page]

Skip to content

Standard Library Structure (@use Directives) #90

Closed

Description

@Mnehmos

Description

Define how NLS ships with built-in semantic domains that users can import.

@use math.core
@use validation.contracts

These are not Python imports — they're semantic building blocks the compiler understands.

Proposed Domains

math.core

  • Unit types (length, mass, time, force, etc.)
  • Dimensional analysis rules
  • Numeric tolerances and comparison

validation.contracts

  • Preconditions, postconditions
  • Invariant helpers
  • Contract composition

system.events

  • Logging semantics
  • State transition patterns
  • Event emission

Acceptance Criteria

  • @use directive syntax added to grammar
  • Compiler resolves @use to bundled .nl files
  • At least one working domain (math.core) with tests
  • Documentation for creating custom domains

Open Questions

  • Where do stdlib .nl files live? (nlsc/stdlib/?)
  • How do user-defined domains interact with stdlib?
  • Versioning strategy for stdlib changes?

Activity

  1. Mnehmos commented on Sep 12, 2026

    @Mnehmos
    OwnerAuthor

    Closing by audit — every acceptance criterion is implemented on master:

    Issue ask Evidence
    @use directive syntax added to grammar nlsc/parser.py directive regex includes use; module.uses in nlsc/schema.py; tree-sitter path handles @use via nlsc/parser_treesitter.py (_sanitize_source_for_treesitter + regex canonical path)
    Compiler resolves @use to bundled .nl files nlsc/stdlib_resolver.py (resolve_use, root precedence: project .nls/stdlib > --stdlib-path > NLS_STDLIB_PATH > bundled nlsc/stdlib), wired into compile/verify/run/watch via nlsc/pipeline.py resolve_stdlib_uses
    At least one working domain (math.core) with tests nlsc/stdlib/MANIFEST.json + nlsc/stdlib/v1/math/core.nl; 7 end-to-end tests in tests/test_issue_90_use_directives.py (bundled resolution, auto parser, EUSE001 on compile and verify, project-local override, CLI > env > bundled precedence)
    Documentation for creating custom domains docs/language-spec.md @use section, docs/cli-reference.md (--stdlib-path, override roots), docs/error-reference.md (EUSE001), docs/design/issue-90-use-directives.md (custom domain layout)

    One scoped caveat, recorded for the record: resolution is metadata-only — resolved stdlib ANLUs are not linked into the emitted program. That was an explicit non-goal of the implemented slice (docs/design/issue-90-use-directives.md, "type checking / export syntax is out of Slice C") and is not in this issue's acceptance criteria; symbol linking across modules belongs to the package model in #146. Also only math.core of the three proposed domains was built — the criterion required "at least one".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    specificationLanguage specification documentsstdlibStandard library

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0