v0.0.5 - 🍏 MacOS / c style for loop, string references, inlinec, make
What's new
Release changes
- MacOS build 🍏
- You need to
chmod +x <binary>
for all the 4 binaries - You need to
xattr -d com.apple.quarantine <binary>
for all the 4 binaries
- You need to
chmod +x carpntr
chmod +x hammer
chmod +x yaksha
chmod +x zig
xattr -d com.apple.quarantine carpntr
xattr -d com.apple.quarantine hammer
xattr -d com.apple.quarantine yaksha
xattr -d com.apple.quarantine zig
- Linux
gnu
libc
build in addition tomusl
build 🐧 - Now the release builds are done using 2 different github actions (Windows 🪟, MacOS 🍏)
- From now on we only support
.7z
archives. (It is cross platform and open source, and lot more efficient than a.zip
file) 🗜️
C Style For
- Alternative loop similar to c-style programming languages.
def main() -> int:
for (x = 0; x < 10; x = x + 1):
println(x)
return 0
String references sr
sr
does not copy strings likestr
, as it is a string reference.- Avoids unnecessary allocations
- Read more in depth - https://yakshalang.github.io/yama/0009_strings_revisited/
- (Various string literal optimisations were done as well)
def do_something(s: sr) -> int:
print("Printing sr: ")
println(s)
return 0
def takes_str(s: str) -> int:
print("Printing str: ")
println(s)
return 0
def main() -> int:
oi = "Oi"
do_something(oi)
takes_str("Oi oi")
return 0
Optimisation
- Initial version of usage analyser and deadcode eliminator.
Better C integration make
and inlinec
@nativedefine("struct foreign")
struct Foreign:
pass
def main() -> int:
a: Ptr[Foreign] = make("Foreign")
b: Ptr[Foreign] = inlinec("Ptr[Foreign]", "make_foreign_ptr()")
return 0
Number autocast
- Now you can assign smaller sized numbers to larger numbers.
- Bool is casted to
1
or0
when assigned to numbers.
def main() -> int:
a = 0
b = True
for (x = 0; x < 10; x = x + 1):
a += b
println(a)
# Note - return can be omitted
0
Libraries
unittest
- New unittest (macros) library.
- Note the
console
import is also required. 💀
import libs.unittest as u
import libs.strings as s
import libs.console as console
u.test_case!{"libs.strings.contains"}:
u.assert_true!{"""strings.contains("", "")""" (s.contains("", ""))}
u.assert_true!{"""strings.contains("a", "a")""" (s.contains("a", "a"))}
u.assert_true!{"""strings.contains("ab", "a")""" (s.contains("ab", "a"))}
u.assert_false!{"""strings.contains("a", "ab")""" (s.contains("a", "ab"))}
u.end_test_case!{}
u.test_case!{"libs.strings.startswith"}:
u.assert_true!{"""strings.startswith("", "")""" (s.startswith("", ""))}
u.assert_true!{"""strings.startswith("a", "a")""" (s.startswith("a", "a"))}
u.assert_true!{"""strings.startswith("ab", "a")""" (s.startswith("ab", "a"))}
u.end_test_case!{}
u.run_all!{}
io
- Various file io functions -
fseek_*
,fwrite
, etc. - Memory mapping io -
mmap
,munmap
, etc. (Works in Windows too 😀)
numbers
- Endian conversion -
to_le16
,to_be32
, etc.
Change Log
- feat(builtins): make and inlinec builtins #48 by @JaDogg in #65
- Feat improvements by @JaDogg in #66
- New
sr
wrapped-string-reference data type by @JaDogg in #67 - feat(compiler,type_checker,tests): implement number auto widen by @JaDogg in #68
- feat(usage_analyser,multifile_compiler,compiler): dead code elimination by @JaDogg in #69
- feat: add c-for, license update by @JaDogg in #70
- few improvements by @JaDogg in #71
Full Changelog: v0.0.4...v0.0.5