Repository navigation
Ascend 1.0: package manager, C-style syntax, structs, lambdas and a full standard library - #4
Merged
Conversation
C-style code now works: for (init; cond; step) loops (also without
parentheses, with comma-separated parts, and `for {}`), ++ and --,
switch/case/default with fall-through, do/while, bodies without braces,
casts like (f64) x, `i32 a = 1, b = 2`, double/long/short, `auto`, and
a main() that runs automatically. printf and sprintf take C formats.
Imports are statements now: `import geometry`, `import lib.shapes as
s`, `import "path" as x`, `from geometry import area, Point as P` and
`from m import *`. The import() function still works.
`struct Point { f64 x; f64 y = 0 }` declares a type with typed fields
and a constructor; struct names work as types everywhere. `enum Color {
Red, Green }` makes a constant map. New regex_* and folder builtins.
Also fixes floats like 20.0 printing as 2e+01.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014xWEy3pVr7ofMaomGRbiuo
- Struct methods with `this`, and init() that runs when a value is made
- Lambdas: x => x * 2, (a, b) => a + b, (i32 n) => { ... }
- List and map comprehensions with nested for and if clauses
- Destructuring: a, b := 1, 2; a, b = b, a; return a, b; x, y := point
- Ranges 0..n and 1..=n (ints and chars), lazy in for/in/switch/match
- Null-safe operators ?? and ?.
- Named arguments for functions and struct constructors
- Variadic ...rest parameters, and ... to spread lists and maps
- finally blocks
- Raw strings r"..." and multi-line strings """..."""
- group_by, count_by, chunk, flat_map, min_by, max_by, mean, median
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014xWEy3pVr7ofMaomGRbiuo
…brary - Inheritance with `struct Dog : Animal`, super.method() and is_a() - Operator overloading (operator+ - * / % ** == < []) and special methods to_string(), iter(), len() and contains() - Typed collections list<T> and map<K, V>, checked on assignment and on later push/insert/extend/element assignment - Tracebacks for uncaught errors through function calls - Programs run on a thread with a large stack: recursion can go 100,000 calls deep instead of about 2,000 - `ascend test` runs *_test.asc / test_*.asc files - run() captures program output; http_get/http_post/http_request via curl; walk_dir, remove_dir, copy_file, move_file, file_size, path helpers, cwd/chdir/temp_dir, set_env, platform - csv_parse/csv_stringify, base64, sha256, uuid, now/format_time, capitalize/title/trim_start/trim_end/last_index_of, lcm, factorial, trunc, degrees/radians, union/intersect/difference - New examples (shapes, scripting, geometry_test), docs and changelog Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014xWEy3pVr7ofMaomGRbiuo
Where the stack runs out (and so the reported column) depends on the machine's stack size, which differs between the CI runners. Check the error and the recursive call in the traceback instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014xWEy3pVr7ofMaomGRbiuo
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.
Takes Ascend from 0.3 to 1.0 in four steps (one commit each), so it can be used as a general-purpose scripting language.
0.4:
apkg, a package managerapkg install / uninstall / list / show / search / init, like pip.colors,colors@1.0.0), GitHub (github:user/repo@v1), any git repository, or a local folder. Dependencies are installed with them.ascend_packages/and list them inascend.json.importfinds installed packages.registry/index.json) starts with three packages written in Ascend:colors,strings,testing.0.5: C-style syntax, imports, structs, enums
for (i32 i = 0; i < n; i++),i++/--i,switch/case/defaultwith fall-through,do/while.(f64) x,auto,double/long/short.main()that runs automatically, andprintf/sprintf.import geometry,import lib.shapes as s,from geometry import area.structwith typed fields, andenum.20.0printing as2e+01.0.6: functions and expressions
thisandinit().x => x * 2), list and map comprehensions, and ranges (0..n,1..=n).a, b = b, a,return lo, hi).??and?., named arguments,...restparameters and spreading.finally, raw strings (r"...") and multi-line strings ("""...""").1.0: complete the language and library
struct Dog : Animal,super.method(),is_a).operator+,==,<,[], ...) and the special methodsto_string,iter,len,contains.list<T>andmap<K, V>, checked when stored and on every later change.ascend testruns*_test.ascfiles.run()captures a program's output.http_get,http_post,http_request.Testing
-Wshadow -Wconversion, no warnings), and under AddressSanitizer and UndefinedBehaviorSanitizer with leak detection.http_getandhttp_postwere tried against real servers. The unit tests only cover what works without a network.Docs updated:
docs/syntax.md,docs/standard_library.md, the newdocs/packages.md,README.mdandCHANGELOG.md. The VS Code grammar now highlights the new syntax.Generated by Claude Code