Commit 50b6f36c

50b6f36c2155Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 8 months ago · 1 file · ~1 modified

Description

Update README with all features: mixin, attr_*, kwargs, splat, strings

17 examples, 6600-line codegen. Full feature table updated with include, attr_accessor, class methods, for..in, loop, keyword args, rest/splat, 15+ string methods, hash, numeric methods.

Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]

Details

Commit
50b6f36c2155
Parent
4b82b7f6e94c

README.mdmodifiedView file

@@ -79,53 +79,49 @@
7979 | Classes with instance variables | `class Vec; def initialize(x,y,z); @x=x; end; end` |
8080 | Inheritance | `class Dog < Animal` |
8181 | `super` | `super(name)` in child initialize/methods |
82-| Method definitions | `def vadd(b); Vec.new(@x+b.x, ...); end` |
83-| Getters/setters (inlined) | `def x; @x; end` / `def x=(v); @x=v; end` |
82+| `include` (mixin) | `class Widget; include Printable; end` |
83+| `attr_accessor/reader/writer` | `attr_accessor :x, :y` |
84+| Class methods | `def self.origin; Point.new(0,0); end` |
85+| Getters/setters (inlined) | auto-generated from attr or manual |
8486 | Object construction | `Vec.new(1.0, 2.0, 3.0)` |
85-| Method calls on typed objects | `ray.org.vsub(@center)` |
8687 | Modules with state | `module Rand; @x = 123; def self.rand; ...; end; end` |
8788 | **Blocks & Closures** | |
8889 | `yield` | `def my_iter(n); yield i; end` |
8990 | Blocks at call sites | `my_iter(10) do \|i\| total += i end` |
9091 | `Array#each/map/select` | `arr.each { \|x\| puts x }` (inlined) |
92+| `Hash#each` | `h.each { \|k,v\| puts k }` |
9193 | `Integer#times` with block | `n.times do \|i\| ... end` |
9294 | Lambda/closures | `-> x { x + 1 }` with capture analysis |
9395 | **Control Flow** | |
94-| `if` / `elsif` / `else` | conditional branching |
95-| `case` / `when` / `else` | pattern matching with values, ranges |
96-| `unless` | `unless x > 20` |
97-| `while`, `until` | loops |
98-| Ternary operator | `escape ? 0 : 1` |
99-| `and` / `or` / `not` | boolean operators |
100-| `break`, `next`, `return` | loop/method exit, continue |
96+| `if`/`elsif`/`else`, `unless` | conditional branching |
97+| `case`/`when`/`else` | values, multiple values, ranges |
98+| `while`, `until`, `loop do`, `for..in` | loops |
99+| Ternary, `and`/`or`/`not` | boolean operators |
100+| `break`, `next`, `return` | loop/method exit |
101101 | **Exception Handling** | |
102-| `begin`/`rescue`/`ensure` | exception handling (setjmp/longjmp) |
103-| `raise` | `raise "error message"` |
104-| `rescue => e` | capture exception message |
105-| `retry` | restart begin block |
106-| **Types & Literals** | |
107-| Integer, Float, Boolean, String, nil | unboxed C types |
108-| Symbol | `:hello` → string constant |
102+| `begin`/`rescue`/`ensure`/`retry` | setjmp/longjmp based |
103+| `raise`, `rescue => e` | string exceptions |
104+| **Parameters** | |
105+| Positional, default values | `def foo(x, y = 10)` |
106+| Keyword arguments | `def greet(name:, greeting: "Hello")` |
107+| Rest/splat | `def sum(*nums)` |
108+| **Types & Collections** | |
109+| Integer, Float, Boolean, String, Symbol, nil | unboxed C types |
109110 | Integer arrays | push/pop/shift/dup/reverse!/each/map/select |
110-| Hash (string→integer) | `h = {}; h["key"] = val; h.each { \|k,v\| }` |
111-| Default parameter values | `def greet(name, greeting = "Hello")` |
112-| **Arithmetic & Operators** | |
113-| Arithmetic, comparison, bitwise | `+`, `-`, `*`, `/`, `%`, `<`, `>`, `==`, `<<`, `\|`, `^`, `**` |
114-| Unary minus | `-b`, `-(expr)` |
115-| `Math.sqrt`, `Math.cos`, `Math.sin` | C math functions |
116-| Integer methods | `abs`, `even?`, `odd?`, `zero?` |
117-| Float methods | `abs`, `ceil`, `floor`, `round` |
111+| Hash (string→integer) | `[]=`, `[]`, `each`, `has_key?`, `delete` |
118112 | **Strings** | |
119-| String literals, interpolation | `"hello #{name}"` → printf |
120-| String methods | `length`, `upcase`, `downcase`, `include?`, `+` |
121-| `Integer#to_s`, `Integer#chr` | number to string conversion |
113+| Literals, interpolation | `"hello #{name}"` → printf |
114+| 15+ methods | length, upcase, downcase, strip, reverse, gsub, sub, split, ... |
115+| Comparison, repetition | `==`, `<`, `"ha" * 3` |
116+| **Arithmetic** | |
117+| All operators | `+` `-` `*` `/` `%` `**` `<<` `\|` `^` `<` `>` `==` |
118+| Math module | `sqrt`, `cos`, `sin` |
119+| Numeric methods | `abs`, `even?`, `odd?`, `zero?`, `ceil`, `floor`, `round` |
122120 | **I/O** | |
123-| `puts`, `print`, `printf`, `putc`, `p` | stdio calls (Int, Float, Bool, String) |
124-| **Other** | |
125-| Parallel/chained assignment | `zr, zi = tr, ti` / `a = b = 0` |
126-| Local variables, constants | `size = 600`, `ITER = 49` |
127-| Array indexing | `basis[0].x`, `@spheres[1].intersect(...)` |
128-| Mark-and-sweep GC | automatic for heap-allocated objects |
121+| `puts`/`print`/`printf`/`putc`/`p` | Int, Float, Bool, String |
122+| **Runtime** | |
123+| Mark-and-sweep GC | shadow stack roots, finalizers |
124+| Arena allocator | for closure-heavy programs |
129125
130126 ## Benchmarks
131127
@@ -145,19 +141,27 @@
145141 ├── src/
146142 │ ├── main.c # CLI, file reading, Prism parsing
147143 │ ├── codegen.h # Type system, class/method/module info structs
148-│ └── codegen.c # Multi-pass code generator (~5000 lines)
149-├── examples/
150-│ ├── bm_so_mandelbrot.rb # Mandelbrot set (while loops, bitwise)
151-│ ├── bm_ao_render.rb # AO raytracer (6 classes, modules)
152-│ ├── bm_so_lists.rb # Array operations (push/pop/shift)
144+│ └── codegen.c # Multi-pass code generator (~6600 lines)
145+├── examples/ # 17 test programs
146+│ ├── bm_so_mandelbrot.rb # Mandelbrot (while, bitwise, PBM)
147+│ ├── bm_ao_render.rb # AO raytracer (6 classes, modules, GC)
148+│ ├── bm_so_lists.rb # Array operations (push/pop/shift, GC)
153149 │ ├── bm_fib.rb # Recursive fibonacci
154-│ ├── bm_app_lc_fizzbuzz.rb # Lambda calculus FizzBuzz (1201 closures)
155-│ ├── bm_mandel_term.rb # Terminal Mandelbrot (cross-function calls)
156-│ ├── bm_yield.rb # yield/blocks (iterators, each/map/select)
157-│ ├── bm_case.rb # case/when, unless, next, default args
158-│ └── bm_inherit.rb # Inheritance, super
150+│ ├── bm_app_lc_fizzbuzz.rb # Lambda calculus (1201 closures, arena)
151+│ ├── bm_mandel_term.rb # Terminal Mandelbrot
152+│ ├── bm_yield.rb # yield/blocks, each/map/select
153+│ ├── bm_case.rb # case/when, unless, next, defaults
154+│ ├── bm_inherit.rb # Inheritance, super
155+│ ├── bm_rescue.rb # rescue/raise/ensure/retry
156+│ ├── bm_hash.rb # Hash operations
157+│ ├── bm_strings.rb # Symbol, basic string methods
158+│ ├── bm_strings2.rb # Advanced string methods, split
159+│ ├── bm_numeric.rb # Numeric methods, power
160+│ ├── bm_attr.rb # attr_accessor, for..in, loop, class methods
161+│ ├── bm_kwargs.rb # Keyword args, rest/splat
162+│ └── bm_mixin.rb # include (mixin)
159163 ├── prototype/
160-│ └── tools/ # Step 0 prototype (RBS extraction, LumiTrace, etc.)
164+│ └── tools/ # Step 0 prototype (RBS extraction, LumiTrace)
161165 ├── Makefile
162166 ├── PLAN.md # Implementation roadmap
163167 └── ruby_aot_compiler_design.md # Detailed design document