Comments (6)
ok, "otherwise" is a feature in optima, which is not implemented in trivia.
The compatibility between optima and trivia is important, but I am reluctant to add the feature to trivia.
- First, although it is in the README of optima, it is not tested in its test suite, so it can be said an "unreliable feature".
- It is generally a better idea to have fewer keywords that are treated specially. The philosopy in Trivia is "everything in defpattern as much as possible". Additional keyword of "otherwise" does not get along with this philosopy. We already have "_" pattern for non-binding variable pattern.
- Finally, the semantics of "otherwise" is not clear: Should it be only allowed in the last clause or is it just an alias to "_"? Considering it is analogous to the use of
cl:otherwise
incl:case
, it should be the latter. It however, introduces another complexity to the code in addition to the second case.
Would you still really want it? if there is an urgent need I am ok with adding it (but probably without the error checking on the non-last clauses).
Thanks for the report anyways.
from trivia.
ok, i should be strict and honest to what i advertize; I will add the feature.
there are some differences between trivia and optima, still.
its a kind of "do your Am486 has the same bug as i486 has?" kind of thing, though.
from trivia.
One solution would be to have different packages: one that is fully compatible, the other that is simpler and purer.
from trivia.
Well, Trivia does advertise itself as follows:
Trivia is a pattern matching compiler that is compatible with Optima. It shares the same testing code with Optima and acts as a drop-in replacement.
A "drop-in replacement" says, at least to me, that if I have a bunch of code written against Optima that works, when I swap out Optima for Trivia it will still work the same. If that is not your goal, then I think you should probably change your blurb to something like "Trivia is similar to Optima, but in some cases has different semantics" [or, perhaps, you'd prefer to say "better semantics" :-)], and, ideally, document those differences.
As to the value of otherwise
, having a default clause at the end is frequently useful, and a lone underscore character is rather inscrutable there, at least to my eyes. From Optima's documentation I've always assumed it is strictly analogous to underscore, though I've never tried it elsewhere. And I do agree with you that it would be better as just something magic for use in the last clause, a la case
(though if that breaks compatibility, then probably not if you really want to be a drop-in replacement). As to complexity of implementation, I (as an end user) obviously think tidiness and usefulness of Trivia as a language trumps ease and tidiness of implementation, but your perspective may well be different.
Thanks!
from trivia.
I newly added test cases for OTHERWISE
. It explicitly allows the use of OTHERWISE
in clauses other than the last one, which means it is completely analogous to _
.
from trivia.
Note that in this topic I did not intend to defend about not implementing OTHERWISE. I just tried to claim it is of less priority and is not necessary (untested, undefined, unreliable feature may not be implemented --- when it worked in optima previously, it just happened to work by luck, since there is no mean to test it.) I finally defined the behavior and implemented it. This is now documented in https://github.com/guicho271828/trivia/wiki/Known-Differences .
@fare , the idea sounds good. Isn't it about assoc
pattern issue though?
from trivia.
Related Issues (20)
- Spurious message when loading trivia HOT 1
- no-applicable-method for mop:compute-slots on structure classes in ABCL HOT 1
- Control stack exhausted when expanding match body with strings HOT 6
- String pattern matching is more strict than STRING= HOT 1
- API unification on multiple values HOT 2
- Stack overflow during ql:quickload from latest Ultralisp dist HOT 8
- guard example from the wiki: invalid number of arguments HOT 2
- TRIVIA does not load in CLISP due to a supposed misplaced declaration HOT 4
- ppcre does not work with recent sbcl (2.1.11, 2.2.1) HOT 4
- Type inference and SATISFIES, GUARD1, etc HOT 2
- Balland optimiser incorrectly fuses patterns for strings of the same length HOT 7
- Destructuring lambda lists don't work HOT 7
- Base string patterns don't match general strings HOT 5
- Match type specifier HOT 2
- Error message for illegal lambda lists is not useful
- Error: guard1 pattern rebinds a variable HOT 2
- Avoid type checking if the type is known HOT 1
- Symbol is unbound in namespace pattern HOT 5
- `return for unknown block: TRIVIA.LEVEL1.IMPL::CLAUSE` with `(type t)` HOT 4
- Fails to load on CMUCL
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 trivia.