Skip to content

Trinary logic on top of "ordinary" Lisp logic? #7

@amno1

Description

@amno1

Hi,

I saw postings about Elsa on the mailing list, and checked it out yesterday.

I think it looks like a great idea and very interesting project. Mostly because, once you have a static analysis, you can do more than just report errors: rewriting (compiling) lisp forms is not far away. For example a Lisp compiler should detect that mapping functions are just for-loops and generate code that eliminates (inlines) both function applied to each element and mapping function itself.

Anyway, this trinary library itself was a little interesting. I thought it looked a bit unusually C-esque, or perhaps in this case JavaScript-esque. I have just rewrote it without using descreete logic (-1, 0, -1) by using generalized booleans from Lisp. I don't know if that works for Elsa, wasn't able to test due to Eask refusing to find tests/elsa-test-helpers.el, but as soon as I get that to work I'll try it in the Elsa context.

Meanwhile, all tests in trinary-logic pass (using Eask and Buttercup). I don't know if that is of interest to you, but I believe it should be slightly more efficient computations.

I have also somewhat "relaxed" "int to trinary" to work more as a generalized boolean:

(cond
   ((> x 0) (trinary-true))
   ((= x 0) (trinary-maybe))
   ((< x 0) (trinary-false)))

That works on any numbers, not just integers, but can easily be converted to work only on fixnums, and with -1, 0, 1. In the context of Elsa, I believe you could have done without trinary-logic at all, since Lisp(s) already have, sort of, trinary logic built-in, but that would be a different discussion, and of not so much practical interest.

Just an idea and a suggestion. If it is of interest I can give you a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions