Code Monkey home page Code Monkey logo

Comments (6)

guicho271828 avatar guicho271828 commented on June 15, 2024 1

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 in cl: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.

guicho271828 avatar guicho271828 commented on June 15, 2024 1

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.

fare avatar fare commented on June 15, 2024 1

One solution would be to have different packages: one that is fully compatible, the other that is simpler and purer.

from trivia.

dfmorrison avatar dfmorrison commented on June 15, 2024

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.

guicho271828 avatar guicho271828 commented on June 15, 2024

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.

guicho271828 avatar guicho271828 commented on June 15, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.