guicho271828 / trivia

Pattern Matcher Compatible with Optima
Other
335 stars 22 forks source link

There shall be only one! #31

Open fare opened 8 years ago

fare commented 8 years ago

Is there any reason not to just replace optima with trivia, then? (Assuming the optima author is willing.)

guicho271828 commented 8 years ago

I partially agree, however @m2ym doesnt seem willing it. Optima is stable but the development has basically stopped. there are tons of issues (well, feature requests actually) that arent resolved yet.

https://github.com/m2ym/optima/issues

guicho271828 commented 8 years ago

to do this, I might have to send a pullreq to the projects using optima to migrate to trivia. is it worth it?

fare commented 8 years ago

grep optima ~/quicklisp/dists/quicklisp/systems.txt | wc -l 33

guicho271828 commented 8 years ago

a kind of experiment. how the authors react?

guicho271828 commented 8 years ago

it looks like it was a haste move. it has some error on clisp.

guicho271828 commented 8 years ago

I should at least wait for the next release.

m2ym commented 8 years ago

I don't have much time to work on CL recently, and I am willing to integrate optima and trivia. What I can do, for example, is

  1. add a link to trivia in README.md
  2. make optima package just an alias for trivia package

@guicho271828 How do you think if we make an organization and a repository like "optima/optima" or "trivia/trivia" (please choose which you prefer) and work on the integration, as you are an author and a core developer?

fare commented 8 years ago

Wow. Congratulations to the two of you for advancing CL pattern-matching!

@m2ym congratulations for having created optima with such talent, then for retiring it with such grace after it did its thing.

@guicho271828 congratulations for furthering the state of CL pattern-matching.

Regarding names: do we want either trivia or optima to be the final name? Wouldn't, e.g. pattern-matching or match be a better name for THE library? I see that the name isn't claimed in cliki, and that http://cliki.net/pattern%20matching doesn't even list trivia yet. It would be nice to pick "THE" name before we ask everyone to switch over. And if possible to make it a stable meaningful name.

Whichever the name ends up being, it could be the name of the package, with trivia and/or optima as nicknames. Or trivia and/or optima could be separate packages that use uiop:define-package to :use-reexport the contents of "THE" real package.

guicho271828 commented 8 years ago

If I merge them seriously, I first have to fix the problem of trivia on clisp and abcl. I havent seriously treated those implementations other than sbcl and ccl.

m2ym commented 8 years ago

@fare If we don't concern about name collision, match or pattern-matching would be nice.

@guicho271828 As I remember, optima is tested on sbcl, ccl, acl, abcl, clisp and ecl. I don't have much care about breaking backward compatibility on minor implementations, but I think It will be great if trivia can work on such implementations.

guicho271828 commented 8 years ago

I spent a day for fixing bugs related to those obscure implementations. now it works.

m2ym commented 8 years ago

@guicho271828 Great! As the first step, I will put a link to trivia on optima's README.

fare commented 8 years ago

@guicho271828 what is the status of trivia with respect to readiness as a replacement for optima?

Do you have parity with all documented optima features? Did you integrate all of optima's test cases in your test suite? Do you run on all the platforms that optima officially supports?

guicho271828 commented 8 years ago
fare commented 8 years ago

Congrats for the successes.

I don't know if any current code uses it, but I remember using when or something equivalent in the days of fare-matcher. Sometimes it's important to guard against arbitrary predicates.

guicho271828 commented 8 years ago

the odd thing re: when/unless is they are infix operators, which are hard to implement in trivia. Actually guard in optima is functionally equivalent to when, so I don't think I will ever support them.

fare commented 8 years ago

Right, as long as the feature is available and documented that's fine.

sionescu commented 4 years ago

Any news on this ?

guicho271828 commented 4 years ago

I don't know what is necessary on this...

mdbergmann commented 4 years ago

the odd thing re: when/unless is they are infix operators, which are hard to implement in trivia. Actually guard in optima is functionally equivalent to when, so I don't think I will ever support them.

What are the options for merging the two regarding this?

guicho271828 commented 4 years ago

the internal designs are very different between the two and I don't think marching is possible. I don't think that infix when is an absolutely necessary feature either. Furthermore, the original author of Optima is no longer active in the common lisp community. Optima is not broken but is sort of in the dead end.

mdbergmann commented 4 years ago

Then maybe it's best to let it be and have 'optima' and 'trivia', separately. There would probably have been some synergies when both would merge. But if the merging costs are too high?

Projects that want to switch from optima to trivia can do so any time. If trivia now supports the common CL implementations this be more or less a drop-in replacement.

guicho271828 commented 4 years ago

If trivia now supports the common CL implementations this be more or less a drop-in replacement.

It is already so for a long time. I don't think anyone new will use optima now

sionescu commented 4 years ago

The problem is that there are lots of libraries that still use it, it's unmaintained and has lots of open bugs. It depends on eos which is also deprecated and doesn't compile on SBCL HEAD, and if I wanted to send a PR to switch Optima to Fiveam there would be nobody to merge it.

fare commented 4 years ago
$ grep optima ~/quicklisp/dists/quicklisp/systems.txt | wc -l
39

This is worse than when I did that in 2016 above. For the migration to happen, someone needs to send patches to all QL project users. And that's not me, I'm not an active CLer anymore.

vindarel commented 4 years ago

btw:

grep trivia ~/quicklisp/dists/quicklisp/systems.txt | wc -l
508
mdbergmann commented 4 years ago

trivia does not have when and unless, a rather obscure optima featrue

So the imcompatibility is mainly due to this? when and unless not available as guards in trivia?

fare commented 4 years ago

I realized that, apart from the compatibility package fare-quasiquote-optima, three of the legacy optima-using contenders were mine: exscribe, inferior-shell, quux-hunchentoot. I did my part to make them use trivia instead, and pushed the results on github, but the real upstream is gitlab.common-lisp.net, to which I seem to have lost access recently with the latest g.c-l.n update.

3 down, a few to go.

guicho271828 commented 4 years ago

@vindarel that is not quite accurate.

guicho271828 commented 4 years ago

trivia does not have when and unless, a rather obscure optima featrue

So the imcompatibility is mainly due to this? when and unless not available as guards in trivia?

yes and I dont think it is one of the core features, hopefully no one is using it...

sionescu commented 4 years ago

@guicho271828 Xach said he could remove Optima from Quicklisp if Trivia could provide an optima.asd which is backwards-compatible. Then we can deal with the libraries that use when/unless.

guicho271828 commented 4 years ago

@sionescu will consider that this weekend

guicho271828 commented 4 years ago

Did my share for the dependencies. Another 3 down. None were breaking due to the change (tested locally).

https://github.com/guicho271828/cl-rrt/commit/00c7ab2d1128eed74ba65a526e2b762f91640838 https://github.com/guicho271828/inner-conditional/commit/9d2626393d50cef5aba2c52374f09ace24150a96 https://github.com/guicho271828/eazy-process/commit/1a7013b9824b36c6d6b10b912e69d20b963f7280

115 provides optima.asd and optima.ppcre.asd where optima.asd provides both optima and optima.extra packages.

I am testing the remaining libraries with my local copy. These libs are the ones directly depending on optima and are beyond my direct control. https://github.com/guicho271828/trivia/pull/115/commits/99c553c7769911adc706b4436b628bb2d6191f94

guicho271828 commented 4 years ago

Among the libraries listed in 99c553c , these libraries failed. I believe some are related to fare-quasiquote:

(("varjo.import" . #<SB-PCL:CLASS-NOT-FOUND-ERROR QUASIQUOTE-VECTOR-PATTERN {10016FC4C3}>)
 ("transparent-wrap" . #<SB-PCL:CLASS-NOT-FOUND-ERROR QUASIQUOTE-VECTOR-PATTERN {10019D85C3}>)
 ("inferior-shell" . #<SB-PCL:CLASS-NOT-FOUND-ERROR QUASIQUOTE-VECTOR-PATTERN {10019D85E3}>)
 ("fare-quasiquote-optima" . #<SB-PCL:CLASS-NOT-FOUND-ERROR QUASIQUOTE-VECTOR-PATTERN {10019D8603}>)
 ("erlang-term-optima" . #<PACKAGE-DOES-NOT-EXIST "The name ~S does not designate any package." {10019D8623}>)
 ("cl-vhdl-tests" . #<SB-PCL:CLASS-NOT-FOUND-ERROR QUASIQUOTE-VECTOR-PATTERN {10019D8663}>)
 ("cl-quil" . #<CFFI:LOAD-FOREIGN-LIBRARY-ERROR "Unable to load foreign library (~A).~%  ~A" {10019D8683}>))
guicho271828 commented 4 years ago

(note: test script in https://github.com/guicho271828/trivia/blob/optima-compat/optima-compat/test.lisp )

So I guess @fare have the one last nail to drive into it

guicho271828 commented 4 years ago

From optima's documentation, when/unless looks like this:

(match list ((list x) when (oddp x) x))
(match list ((list x) unless (evenp x) x))

In trivia this would be just parsed as (list x) pattern plus a body consisting of an undefined variable when, unused test (oddp x) and a reference x, thus it does not result in the compile error (SBCL may throw warnings though).

guicho271828 commented 4 years ago

in the libraries tested above, I did not see the warnings. Therefore, when/unless are probably never used.

guicho271828 commented 4 years ago

With this commit https://github.com/fare/fare-quasiquote/pull/1 which redirects fare-quasiquote-optima to triva.quasiquote, the failed libs reduced to two; likely cl-quil would still continue to work if I manage to find the foreign lib.

(("erlang-term-optima" . #<PACKAGE-DOES-NOT-EXIST "The name ~S does not designate any package." {101D8A4763}>)
 ("cl-quil" . #<CFFI:LOAD-FOREIGN-LIBRARY-ERROR "Unable to load foreign library (~A).~%  ~A" {10016698B3}>)) 
fare commented 4 years ago

Note that there is already a erlang-term-trivia in cl-erlang-term next to erlang-term-optima, so maybe just make it a redirection, or remove it?

guicho271828 commented 4 years ago

Some library may be depending on cl-erlang-optima, but if there are none it can be removed. Is it your library?

guicho271828 commented 4 years ago

I forgot that it was me who implemented the trivia port...

fare commented 4 years ago

The author of https://github.com/flambard/cl-erlang-term is @flambard.

guicho271828 commented 4 years ago

pointing @quicklisp here (hope this notifies him)