Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor lisp functions #478

Merged
merged 9 commits into from
Apr 22, 2023
Merged

Refactor lisp functions #478

merged 9 commits into from
Apr 22, 2023

Conversation

vinc
Copy link
Owner

@vinc vinc commented Apr 14, 2023

  • Rename print to p and println to print
  • Rename string-join to join-string (aliased to join-str)
  • Use atom? instead of atom by default
  • Use equal? instead of eq by default
  • Use variable (aliased to var) instead of define
  • Keep define shortcut (aliased to def) for define-function
  • Add str, str->num, str->bin, bin->str aliases
  • Add num-type, num->bin, bin->num aliases
  • Add uniq, rev, and len aliases
  • Add bool?, str?, sym?, num?, fun?, mac? aliases
  • Use short aliases in core, doc, and examples

@vinc
Copy link
Owner Author

vinc commented Apr 14, 2023

This change of keyword syntax will make the language a bit more in line with something like Ruby or JavaScript which might be easier for beginners using the OS. And the aliases make it shorter. The syntax is pretty close to the Janet language that I discovered this week!

(load "/lib/lisp/core.lsp")

(def (foobar n) (do
  (var i 1)
  (while (< i n) (do
    (if (and (= (% i 3) 0) (= (% i 5) 0))
      (print "foobar")
      (if (= (% i 3) 0)
        (print "foo")
        (if (= (% i 5) 0)
          (print "bar")
          (print i))))
    (set i (+ i 1))))))

(foobar 100)

It'd be great to add an implicit do to def and while.

@vinc vinc merged commit 4d50eae into trunk Apr 22, 2023
@vinc vinc deleted the feature/lisp-refactor branch April 22, 2023 13:46
@vinc vinc mentioned this pull request Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant