Skip to content

Releases: sigmasoldi3r/charon-lang

Fixed multiline string code generation

27 Sep 09:11
Compare
Choose a tag to compare
Pre-release
  • Fixed a bug that was making the string generated not valid for Lua.
(println! "This is
Fine in
Charon")

But in Lua:

print("Not
valid")
-- Instead now generates:
print("Is valid\nYes")

Variadic functions, inline declare and bugfixes.

23 Sep 13:06
Compare
Choose a tag to compare
  • Fixed a bug that made two embed runtimes incompatible.
    • The bug consisted of each runtime comparing types by reference with their own symbol tables, which led to one runtime seeing as "object" all the values of the other runtime.
    • Now uses a nominal system, where each type has also a __name meta field.
  • Fixed a bug that was preventing the use of (declare ...) locally inside functions and other blocks.
  • Added table/map function for mapping tables: The function works like list's map, but must return a key-value pair like [k v].
  • Added table/empty? function that tells if the table is empty or not.
  • Added table/items function which returns a list of key-value pairs.
  • Added Variadic functions! yay! The syntax is the same of Clojure: (defn a-fn [x y & z] ...) Here z is the variadic term (A list).
  • Added a very primitive run flag with -u or --run, creates a temporary file that then is run with the command lua and deleted right after.

Fixed object manipulation and enhanced scoping of functions and variables.

20 Sep 10:43
Compare
Choose a tag to compare

Now you can export global-level functions just by adding :global as first expression of the function.

(defn package-level []
  "hey")

(defn global-func [] :global
  "awesome, huh?")

The scoping now is divided in package, local and global.
If you want to return the symbol :global from a function you can escape it's "decorator" behaviour by adding a unit as first
expression:

(defn what-symbol []
  unit ; Basically a noop-expression
  :global)

Also object/set was not doing fine when converting symbols to string keys. If desired, a symbol key can be used by invoking object/set-raw:

(object/set o1 :my_key "Hello")
(object/set-raw o2 :my_key "Hello")

Those translate roughly to:

o1.my_key = "Hello";
o2[charon.symbol"my_key"] = "Hello";

Which is different, specially when talking about POLT objects.

Object literals added to the language

11 Sep 10:21
Compare
Choose a tag to compare
Pre-release

Prior to that, for interoperate with Lua, when a plain old lua table (POLT for short) was needed, you had two options:

  • Provide a table with string keys
{"like" "this"}
  • Or convert a table to object with the object/new function, which is done at runtime.
(object/new {:like "this"})

Now, you can have POLT values compiled statically, so you don't waste process time and memory:

; This will be translated to a POLT value
'{:note "the single quote"}

Fixed runtime type checking and added functions for typecheck

03 Aug 11:26
Compare
Choose a tag to compare

You can check the file samples/typecheck.crn to see it in action.

The (type) function had a bug so it couldn't determine the types properly.

Bugfix: Runtime extract will ignore global option

26 Jul 14:22
Compare
Choose a tag to compare

Fixed a bug that was making the --runtime-extract option ignore the --global-export one.

This made the extracted runtime to have local exports even if the global export flag was passed.

Major api naming changes, better export tuning.

26 Jul 14:14
Compare
Choose a tag to compare

Now you can tune your export by declaring a module global with the flag --global-export or -g and avoid requiring the runtime (If not embedding) by passing the --no-require or -n flag.

Added module macro to declare explicitly the name of the module, otherwise the file path is used as name (minus the extension).

; Example
(module my-mod
  [:import lib :from "lib"])

Other syntax changes:

Old New
def defn
def-impure defn!
def-value def
def-extern declare

Pattern matching & destructuring

24 Jul 09:55
Compare
Choose a tag to compare
Pre-release

Added pattern matching and destructuring assignment.

  • Now when expression can match against destructured tuples.
  • Let bindings can destructure tuples.
  • Shifted # to _ for default fallback.

Examples:

(let [val ["a" 5 {:yes "you"}]]
  (println! "Example: "
    (when val
      ["a" _ _] "Was A!"
      [_ 5 _] "Was 5!"
      _ "No match...")))
(let [tpl ["a" :b 5]]
  (let [[a b c] tpl] ; Ease of destructure in let bindings, for example.
    (println! tpl)
    (println! "a: " (:0 tpl)) ; Table-like element access
    (println! "a: " a)
    (println! "b: " b)
    (println! "c: " c)))

Added field access expressions

21 Jul 08:25
Compare
Choose a tag to compare
Pre-release

One of the biggest issues with accessing fields inside objects was the lack of access expressions for them.
Now, by using the unbounded access operator :: you can reference a field (Either method or other value...).

Bound reference : will cause a syntax error for now, in the future can be used to bind methods (Proposal pending).

;; Example:
(+ 1 some-obj::some-number)

Changelog

  • Added unbounded access expression for fields a::b::c.
  • Fixed runtime errors related to list methods.
  • Now range produces a list instead of an anonymous iterable object.
  • Import now can import non-binding packages (Anonymous import) like (import "some-pkg")
  • Embed runtime will produce now a do ... end block instead of an IIFE.
  • Better error reporting (Less clutter and internal traces).

Bugfix for list literals

17 Jul 09:13
Compare
Choose a tag to compare
Pre-release

The compiler was generating a charon.vector call which is invalid for list literals [].

Now generates a proper charon.list{} call.

  • Also added better formatting for tables when converted to string.
  • Added runtime assertions for object/get for better error reporting.