Skip to content

iscon, isstr, isnum, isfloat, ispn, isarray type tests (#447) (4.2.34) - #790

Merged
ddehilster merged 1 commit into
masterfrom
feature/type-tests-447
Oct 15, 2026
Merged

ddehilster merged 1 commit into
masterfrom
feature/type-tests-447

Conversation

@ddehilster

Copy link
Copy Markdown
Member

Closes #447. Follows the review choice of separate is* builtins.

builtin 1 when the value is
iscon(x) a KB concept
isstr(x) a string, including "" and digit strings like "42"
isnum(x) an integer
isfloat(x) a float
ispn(x) a parse tree node
isarray(x) an array (a value with several elements)
  • Each returns 1 or 0 and never warns, even for an empty value. Passing more than one argument is an error.
  • Unset variables: in NLP++ an unset variable reads as 0, so isnum(L("unset")) is 1. iscon, ispn and the rest are 0 for it, which is what guards like if (!iscon(L("c"))) need.
  • Compiled analyzers reach them through bridgedFns.
  • No name collisions: I searched the analyzers in nlp-engine, visualtext-files, package-analyzers and analyzers, and none define functions with these names.

Tests:

  • New fixture tests/type-tests runs every builtin on a concept, a string, a digit string, an empty string, an integer, a float, a node, an array and an unset variable, plus direct calls. CI steps run on Windows and Linux.
  • Local: 48/49 CI steps pass. The compiled-bridge step needs $GITHUB_WORKSPACE and always fails locally.
  • Full English Test: unchanged.
  • 20 analyzers × 21 inputs: 0 differences.
  • The compiled fixture gives the same output as the interpreter.

Docs: VisualText/visualtext-files PR follows. Batched: don't tag yet.

🤖 Generated with Claude Code

NLP++ is loosely typed and passing the wrong kind of value often fails
silently. Six builtins test a value's kind and return 1 or 0, without
warnings even for empty values. A numeric string is a string; an unset
variable reads as 0, so it is a num. Compiled analyzers reach them
through the builtin bridge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ddehilster
ddehilster merged commit 6690e6c into master Oct 15, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NLP++ type checking

1 participant