Skip to content

[14/15] Nothing states quickr's semantic contract or where compiled code diverges from R #135

Description

@mns-nordicals

What's missing

quickr's value proposition rests on a promise: a compiled function behaves
like the R function it was compiled from. Nothing in the package writes that
promise down, or says where it stops holding.

  • There is no vignettes/ directory and no VignetteBuilder in
    DESCRIPTION — the package has no long-form documentation at all.
  • README.md covers installation, usage, declare() syntax, and benchmarks.
    It does not state the value/type/shape contract, and mentions no divergence
    from R.
  • The reference docs describe individual functions, so a rule that spans
    operations — "which result type do you get when modes are mixed", "when is
    a shape mismatch a compile error and when is it a runtime check" — has no
    home.

The result is that every semantic question has to be answered by reading
R/r2f-*.R or by experiment.

Why it matters

This series makes the gap much more visible, because it settles a long list
of semantic questions and several answers are deliberately not R's:

  • R-style partial recycling is rejected rather than implemented.
  • 1×1-matrix operands follow R's arithmetic/comparison split, and at
    symbolically-known lengths quickr errors where R would recycle.
  • A variable's type is fixed at first binding, so x <- x + 0.5 on an
    integer x is a compile error.
  • NA is not supported; zero-length operands combine only with scalars.
  • Complex values are elementwise-only — type joins and linear algebra
    refuse them.
  • Subscript bounds checking is deliberately partial: literal subscripts are
    validated against known extents, but a symbolic scalar subscript x[i] is
    unchecked at run time, matching Fortran's contract rather than R's. That
    is a considered performance decision — per-subscript guards in hot loops
    defeat the point of a compiler — and a decision like that has to be
    documented to be defensible.

Users hitting any of these need to be able to tell "deliberate divergence,
here's why" from "bug, please report it". Right now they cannot.

Expected content

A vignette that states, once:

  1. The contract. quick(f)(x) returns exactly what f(x) returns — same
    values, same typeof(), same shape — or raises an error. Plus the
    compile-error/runtime-check split: refuse at compile time when the answer
    is knowable then, guard at run time when it needs runtime values.
  2. Result types. The promotion order and a per-operation result-type
    table, plus the fixed-variable-type rule.
  3. Shapes. The three verdicts (provably fine / provably wrong / checked
    at run time), the elementwise compatibility table, the supported recycling
    forms, and linear-algebra conformability.
  4. Differences from R, each with its rationale, so the deliberate
    divergences are on the record.

It should carry no build-time cost: chunks not evaluated, outputs pasted from
verified runs, so building the vignette needs no Fortran toolchain and adds
nothing to R CMD check.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions