Comments (5)
Another option would be to indent the cases:
match _first
| None => _first = ex'
| as ex: Exchange =>
_first = None
end
This makes things clearer to me, but then has the problem that it looks like there's an end mssing after the last case.
from ponyc.
I prefer the pipe symbol, possibly because it's familiar from OCaml, etc. The only concrete reason I have for preferring it is for cases like this:
match x % 100
| 11 | 12 | 13 => "th"
else
match x % 10
| 1 => "st"
| 2 => "nd"
| 3 => "rd"
else
"th"
end
end
Note the combination of the initial 11, 12 and 13 cases.
from ponyc.
Let's try the same example with a keyword, I'm using case because I'm lazy.
One case per line option:
match x % 100
case 11
case 12
case 13 => "th"
else
match x % 10
case 1 => "st"
case 2 => "nd"
case 3 => "rd"
else
"th"
end
end
And the same with case indentation:
match x % 100
case 11
case 12
case 13 => "th"
else
match x % 10
case 1 => "st"
case 2 => "nd"
case 3 => "rd"
else
"th"
end
end
Cases grouped on a line option:
match x % 100
case 11 case 12 case 13 => "th"
else
match x % 10
case 1 => "st"
case 2 => "nd"
case 3 => "rd"
else
"th"
end
end
And the same with case indentation:
match x % 100
case 11 case 12 case 13 => "th"
else
match x % 10
case 1 => "st"
case 2 => "nd"
case 3 => "rd"
else
"th"
end
end
I think that works well either on separate lines or grouped on a line, but it's definitely better with cases indented
from ponyc.
I agree with Andy that indentation is good. After all, you also use indentation for the two branches of an if-statement.
from ponyc.
We've decided to keep the pipe and not replace it with a keyword.
from ponyc.
Related Issues (20)
- Release 0.52.5 HOT 1
- Compiler crash when attempting to mutate a val field HOT 1
- Release 0.53.0 HOT 1
- Vague error messages when it is not safe to write HOT 1
- Compiler "hangs" in function pass HOT 5
- Release 0.54.0 HOT 3
- Incorrect argument names and counts in dtrace probes documentation. HOT 3
- Missing index check on desc_table array access in runtime deserialization pony_deserialise_offset HOT 3
- Is bootstrapping implemented? HOT 1
- Incorrect generic FFI syntax compiles HOT 10
- Runtime crash when accessing a field that was captured before it was initialized HOT 2
- Feat: Reconsider support for ponyc bundled builds targeting Intel MacOS HOT 1
- runaway memory growth during GC with reference cycle HOT 12
- RFC #77: Assign Param Syntax
- RFC #78: Remove JSON package from the standard library
- Can't built 0.53.0 on aarch64-darwin HOT 8
- Possible violation of the `pthread_create` interface? HOT 4
- Release 0.54.1 HOT 2
- iftype compile error at runtime HOT 7
- [Epic] EL 9 & Fedora support - prebuilt, install.md, and ponyup HOT 1
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 ponyc.