about summary refs log tree commit diff stats
path: root/Makefile
Commit message (Collapse)AuthorAgeFilesLines
* separated several functions into view.cAnselm R. Garbe2006-08-221-1/+1
|
* removed finished messageAnselm R.Garbe2006-08-141-1/+0
|
* applied Sanders LD and resize patchesAnselm R.Garbe2006-08-141-1/+2
|
* applied Sanders tiny patchesAnselm R.Garbe2006-08-081-1/+1
|
* typo fixarg@10ksloc.org2006-08-071-1/+1
|
* applied Sanders man page/Makefile patcharg@10ksloc.org2006-08-071-1/+1
|
* added stripping to dwm target in Makefilearg@10ksloc.org2006-08-071-0/+1
|
* removed CONFIGarg@10ksloc.org2006-08-031-3/+2
|
* make config.h not a time dependencearg@10ksloc.org2006-08-031-1/+1
|
* removed rm config.h from cleanarg@10ksloc.org2006-08-031-1/+1
|
* added gmake compliancearg@10ksloc.org2006-08-031-2/+2
|
* applied Jukka's diffarg@10ksloc.org2006-08-031-4/+5
|
* applied Sanders Makefile patcharg@10ksloc.org2006-08-031-26/+20
|
* using SRC instead of *.carg@10ksloc.org2006-08-031-1/+1
|
* changed the files included in make distarg@10ksloc.org2006-08-031-1/+2
|
* applied Sanders doc changes, added a PHONY line and changed the output of ↵arg@10ksloc.org2006-08-031-1/+4
| | | | config.h creation somewhat
* implemented the idea presented by Sander for dwm targetarg@10ksloc.org2006-08-021-1/+4
|
* applied Sanders patchesarg@10ksloc.org2006-08-011-2/+1
|
* makefile now sets permissions for executables and man pagesarg@10ksloc.org2006-07-201-0/+6
|
* simplified MakefileAnselm R. Garbe2006-07-171-2/+2
|
* rearranged several stuffAnselm R. Garbe2006-07-151-1/+1
|
* rearrangedAnselm R. Garbe2006-07-141-1/+1
|
* draw bar on exposure ;)Anselm R. Garbe2006-07-141-1/+1
|
* prep 0.1 0.1Anselm R. Garbe2006-07-141-1/+1
|
* implemented bar for dwm (I miss status text), I plan that status text is ↵Anselm R. Garbe2006-07-141-1/+1
| | | | read from stdin in dwm
* changed default colorsAnselm R. Garbe2006-07-131-2/+2
|
* added dev.c instead of kb.cAnselm R. Garbe2006-07-131-1/+1
|
* added logo+descriptionAnselm R. Garbe2006-07-131-12/+12
|
* removed unnecessary crapAnselm R. Garbe2006-07-131-16/+10
|
* added grid mode on Mod1Mask gAnselm R. Garbe2006-07-121-1/+1
|
* added mouse-based resizalsAnselm R. Garbe2006-07-111-1/+1
|
* removed unnecessary sel stuffAnselm R. Garbe2006-07-111-8/+2
|
* added gridsel to gridwmAnselm R. Garbe2006-07-111-2/+8
|
* added key handlingAnselm R. Garbe2006-07-111-1/+1
|
* added several other stuffAnselm R. Garbe2006-07-101-2/+2
|
* renamed gridmenu.c into menu.cAnselm R. Garbe2006-07-101-1/+1
|
* several new changes, made gridmenu workingAnselm R. Garbe2006-07-101-4/+10
|
* added new stuffAnselm R. Garbe2006-07-101-6/+6
|
* added gridmenuAnselm R. Garbe2006-07-101-3/+35
|
* initial importAnselm R. Garbe2006-07-101-0/+23
ass="s"> _ _ then "neither zero"; /* Table pattern matching */ process_user : user -> when user is {status: "admin"} then "Admin access granted" {status: "user", verified: true} then "User access granted" _ then "Access denied"; ``` ### 3. **Tables (Lua-like)** ```baba-yaga /* Array-like tables */ numbers : {1, 2, 3, 4, 5}; first : numbers[1]; /* 1-indexed */ /* Object-like tables */ person : {name: "Bob", age: 25}; name : person.name; /* Mixed tables */ mixed : {1: "first", name: "Alice", 2: "second"}; /* Nested tables */ company : { name: "TechCorp", employees: { {name: "Alice", role: "Engineer"}, {name: "Bob", role: "Designer"} } }; ``` ### 4. **Function References & Composition** ```baba-yaga /* Function references with @ */ double_ref : @double; result : double_ref 5; /* 10 */ /* Function composition */ increment : x -> x + 1; composed : compose @double @increment 5; /* double(increment(5)) = 12 */ piped : pipe @increment @double 5; /* increment(double(5)) = 11 */ /* Partial application */ add_ten : add 10; /* Partially applied function */ result : add_ten 5; /* 15 */ ``` ### 5. **Immutable Table Operations** ```baba-yaga /* t.* namespace for table operations */ original : {name: "Alice", age: 30}; /* All operations return new tables */ updated : t.set original "age" 31; deleted : t.delete original "age"; merged : t.merge original {city: "NYC"}; /* Functional transformations */ numbers : {1, 2, 3, 4, 5}; doubled : t.map (x -> x * 2) numbers; evens : t.filter (x -> x % 2 = 0) numbers; sum : t.reduce (x y -> x + y) 0 numbers; /* Table metadata */ shape : t.shape numbers; /* {size: 5, type: "array"} */ has_name : t.has original "name"; /* true */ length : t.length original; /* 2 */ ``` ### 6. **IO Operations** ```baba-yaga /* Output */ ..out "Hello"; ..out 42; ..out {name: "Alice"}; /* Input (context-dependent) */ input_value : ..listen; /* Assertions for testing */ ..assert 2 + 2 = 4; ..assert factorial 5 = 120; /* Event emission (for integration) */ ..emit "user_logged_in" {user_id: 123}; ``` ## Style Guide & Best Practices ### **Naming Conventions** ```baba-yaga /* Variables: snake_case */ user_count : 42; max_retries : 3; /* Functions: descriptive verbs */ calculate_tax : amount -> amount * 0.08; validate_email : email -> /* validation logic */; /* Constants: ALL_CAPS (when obvious) */ PI : 3.14159; MAX_CONNECTIONS : 100; ``` ### **Function Design** ```baba-yaga /* DO: Good: Pure, composable functions */ add_tax : rate amount -> amount * (1 + rate); format_currency : amount -> "$" + amount; /* DO: Good: Single responsibility */ is_adult : person -> person.age >= 18; get_adult_names : people -> map (p -> p.name) (filter @is_adult people); /* DON'T: Avoid: Complex nested logic */ /* Use helper functions instead */ ``` ### **Pattern Matching Style** ```baba-yaga /* DO: Good: Exhaustive patterns */ handle_response : response -> when response is {status: 200, data: data} then process_success data {status: 404} then handle_not_found {status: _} then handle_error response _ then handle_unexpected response; /* DO: Good: Guard patterns for ranges */ categorize_age : age -> when (age < 13) is true then "child" false then when (age < 20) is true then "teen" false then when (age < 65) is true then "adult" false then "senior"; ``` ### **Table Operations** ```baba-yaga /* DO: Good: Functional pipeline style */ positive_numbers : filter (x -> x > 0) numbers; doubled_numbers : map (x -> x * 2) positive_numbers; result : reduce (x y -> x + y) 0 doubled_numbers; /* DO: Good: Immutable updates */ user_with_login : t.set user "last_login" "2023-12-01"; updated_user : t.set user_with_login "login_count" (user.login_count + 1); /* DON'T: Avoid: Complex nested table access */ /* Extract to helper functions */ ``` ### **Error Handling** ```baba-yaga /* DO: Good: Use pattern matching for error cases */ safe_divide : x y -> when y is 0 then {error: "Division by zero"} _ then {result: x / y}; /* DO: Good: Validate inputs early */ process_user : user -> when user is {name: name, age: age} then when (age >= 0) is true then {status: "valid", user: user} false then {error: "Invalid age"} _ then {error: "Invalid user data"}; ``` ## Language Limitations & Workarounds ### **Parser Limitations** ```baba-yaga /* DON'T: Nested lambda expressions not supported */ /* y_comb : f -> (x -> f (x x)) (x -> f (x x)); */ /* DO: Use helper functions instead */ y_helper : f x -> f (x x); y_inner : f x -> y_helper f x; y_comb : f -> y_helper f @y_inner; /* DON'T: Complex when expressions in table literals */ /* classifier : { classify: x -> when x is 0 then "zero" 1 then "one" _ then "other" }; */ /* DO: Define functions externally */ classify_func : x -> when x is 0 then "zero" 1 then "one" _ then "other"; classifier : {classify: classify_func}; ``` ### **When Expression Syntax** ```baba-yaga /* DON'T: Direct boolean conditions */ /* abs : x -> when x < 0 then -x; */ /* DO: Explicit boolean patterns */ abs : x -> when (x < 0) is true then -x _ then x; ``` ### **No Array Literals** ```baba-yaga /* DON'T: Array syntax not supported */ /* list : [1, 2, 3]; */ /* DO: Use table syntax */ list : {1, 2, 3}; /* DON'T: Array concatenation */ /* result : list concat [4, 5]; */ /* DO: Use table operations */ result : t.append (t.append list 4) 5; /* Or use a helper function for multiple appends */ ``` ## Standard Library Highlights ### **Combinators** ```baba-yaga /* map, filter, reduce - work on tables */ doubled : map (x -> x * 2) numbers; evens : filter (x -> x % 2 = 0) numbers; sum : reduce (x y -> x + y) 0 numbers; /* Function composition */ f_g : compose @f @g; g_f : pipe @g @f; applied : apply @f x; /* Currying and partial application */ add_ten : add 10; multiply_by : flip @multiply; ``` ### **Table Operations (t. namespace)** ```baba-yaga /* Core operations */ length : t.length table; has_key : t.has table "key"; value : t.get table "key" "default"; /* Transformations */ mapped : t.map @function table; filtered : t.filter @predicate table; reduced : t.reduce @combiner initial table; /* Updates (immutable) */ updated : t.set table "key" value; removed : t.delete table "key"; combined : t.merge table1 table2; /* New operations */ shape : t.shape table; /* {size: N, type: "array"|"object"} */ extended : t.append table value; prefixed : t.prepend table value; ``` ### **Utilities** ```baba-yaga /* Arithmetic with type coercion */ "Alice" + 10; /* "Alice10" - string concatenation */ true + 10; /* 11 - boolean to number */ 30 + 12; /* 42 - numeric addition */ /* Logical operations with truthiness */ result : 1 and 1; /* true */ result : 0 or "text"; /* "text" */ result : not false; /* true */ ``` ## Integration Patterns ### **Side-Effect Isolation** ```baba-yaga /* Pure functional core */ process_data : data -> calculate (transform (validate data)); /* Side effects at boundaries */ main : input_data -> result : process_data input_data; ..emit "data_processed" result; ``` ### **Testing Pattern** ```baba-yaga /* Test with assertions */ test_factorial : -> ..assert factorial 0 = 1 ..assert factorial 5 = 120 ..assert factorial 1 = 1; /* Property testing */ test_reverse_property : list -> ..assert (reverse (reverse list)) = list; ``` ## Implementation Status - **JavaScript**: Reference implementation (100% complete) - **C**: Production implementation (97.1% test compatibility) - **Shared Test Suite**: 34/35 tests passing (97.1% success rate) ## Further Reading - **Detailed Tutorials**: `js/tutorials/` - Comprehensive language guide - **API Reference**: `js/tutorials/11_Standard_Library.md` - Complete function reference - **Advanced Patterns**: `js/tutorials/14_Advanced_Combinators.md` - Complex functional patterns - **Integration Guide**: `js/tutorials/15_Integration_Patterns.md` - Using Baba Yaga in larger systems ## Philosophy & Design Baba Yaga emerged from a simple question: *What if pattern matching was the primary control flow mechanism?* The language embraces: - **Functional purity** with controlled side effects - **Immutable data** with efficient operations - **Combinator composition** over imperative loops - **Expression-based** rather than statement-based syntax - **Minimal but powerful** standard library The result is a language that encourages thinking in terms of data transformations and function composition, leading to more declarative and maintainable code. --- *"In the deep dark woods, where functions compose and data flows immutably, there lives Baba Yaga - a language both beautiful and dangerous, simple yet powerful."*