Repository navigation
Move non-core built-ins into standard library modules - #32
Merged
Merged
Conversation
The basics stay importless: printing, conversions and the operations on strings, arrays and maps. Math functions now need std/math, random numbers std/random, clocks and sleep std/time, parseJSON and toJSON std/json, file functions std/fs, env, args, exit and panic std/process, assert std/testing, and the character classes std/strings. A missing import is reported once per module with a fix that adds it, so burn fix migrates code; burn eval and the REPL keep everything. The language server completes these functions with an auto-import and shows their module in hovers, and burn doc lists it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The basics stay built in and need no import:
typeOflen,.push,.split,.trim, …)Everything else now belongs to the standard library module it fits:
std/mathsqrt pow abs floor ceil round min max sin cos tan asin acos atan atan2 log log10 expstd/randomrandom randomInt seedstd/timenow nowMs millis clock sleepstd/jsonparseJSON toJSONstd/fsreadFile writeFile appendFile fileExistsstd/processenv args exit panicstd/testingassertstd/stringsisLetter isDigit isAlphanumeric isWhitespaceThey stay fast built-ins at runtime; only their visibility depends on the import.
How
`sqrt` is in the standard library module `std/math`.import "std/math"after the last import, or at the top.burn evaland the REPL keep everything without imports.burn fixadds all missing imports at once.import "std/math"".burn doc: builtin pages show an Import tag.burn init: the library template's test importsstd/testingforassert.Migration in this repository
burn fixadded the imports to:tests/casesburnfmtThe only diffs are added imports.
tests/cases/numbers.outchanges only by the shifted line numbers.The docs are updated too:
docs/stdlib/builtins.mdxhas a new "In the standard library" section with the table.std/mathandstd/fsdocs no longer say these need no import.Tests
tests/errors/std_import.burn fixfixture now also addsimport "std/math"(8 fixes).burnfmt --check, examples, andburn init+burn build.Merge burnlang/ash#6 first. ash uses some of these functions; its migration adds the imports and also works with the current Burn.
🤖 Generated with Claude Code
Generated by Claude Code