Comments (3)
Current Onyx:
foo(x Foo|Bar|Qwo) ->
match x
Foo => say "a Foo: { x.foo-stuff }"
Bar => say "a Bar: { x.bar-stuff }"
Qwo => say "a Qwo: { x.qwo-stuff }"
* => say "This won't happen"
a = switch rnd 1..3
1 => Foo()
2 => Bar()
3 => Qwo()
foo a
(match
is currently just an alias for switch
— still awaiting settling of some other features before implementation with destructuring syntax)
It should be rather clear at this point that union types are a fundamental part of Onyx?
from onyx-lang.
No, to really use tagged unions, you need to be able to do destructuring like this:
match object
Circle x y r => say "A circle with radius {r}"
Rect x1 y1 x2 y2 => say "A rectangle from {x1}, {y1} to {x2,y2}"
from onyx-lang.
Was that tl;dr for you? ;-)
still awaiting settling of some other features before implementation with destructuring syntax
from onyx-lang.
Related Issues (20)
- Is this still being maintained? HOT 1
- Idea: replacing `+=` etc. with the canonical "self-call-assign" HOT 4
- Feature: terse array literals HOT 1
- Taking a look at how to effectively further the project HOT 5
- GUI in ONYX ? HOT 2
- [Question] Does this language has reader macros implemented and supports template programming? HOT 2
- Ditch Global Variables from the Language (Use Type Scoped Vars for Those Cases) HOT 4
- `Self` and `this` vs Other Namings HOT 3
- Feature: spread operator HOT 4
- Dead? HOT 4
- So it's dead then? HOT 3
- `in` operator HOT 1
- Tool: Stylizer / Formatter
- Type Reasoning Keywords HOT 20
- Allow Prime (Apostrophe in Reality) Signs at End of Identifiers HOT 10
- Anon function self-reference syntax HOT 1
- "Route '66 Style"* Syntax For Code Blocks (Braces) HOT 18
- Syntax Flow, Unresolved Ideas - Suggestions Welcome HOT 2
- Write Documentation for Onyx Lang HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from onyx-lang.