// Single Line
/*
Multi-Line
Comment
*/
@package Main
@if @true {
// ...code...
}
// Let is for constants
// Strings are immutable unless you use
@let name @str : "John"
@let name : "John"
$name : "John"
@let age @num : 28
@let age : 18
$age : 18
$$MAX : 10
@ - Keywords
@@ - Annotations
$ - Let Declaration
$$ - Var Declaration
^ - Nominal Type prefix
~ - Structural Type prefix
! - Mutable variable or method suffix Like convention in Ruby except this is enforced by the compiler.
// Mutable string
@str!
// Method mutates passed data. Compiler enforces that at least one parameter is passed by reference and modified for functions and that at least a field or property is modified for methods.
#Reverse! arr
# - Method Call prefix
#Add 1,3
_ - Placeholder
[0:_]
@for ;_ < 10; {
}
a, _ : #GetTwoValues
? - Optional suffix (Like Nullable)
@num?
@let Div? $a $b : $b = 0 ? @nil : $a / $b
Silicon / Sigil is a strongly statically typed language with a very strong but flexible type system. You'll rarely see types explicitly declared as the compiler does type inference (but not auto conversion).
Silicon uses type hierarchies / unions to simplify the type system (making it run as an interpreted language quiet well too).
@num - signed integer Union of int(8|16|32|64|128) and float(32|64|128). Unlike C unions only the memory size of the used type. Generic Union or Dynamic Union. Like how we can declare an array of arbitrary size.
@nat - natural number uint(8|16|32|64|128)
@str - immutable string supports Unicode
@str! - mutable string supports Unicode
@bool - boolean @true | @false. Alias for @Bits(1).
@char - UTF-8 /16 and Unicode support. Alias for uint8 / uint16 but with different Nominal type which then has different methods / operators associated with it as well.
@bits - An arbitrarily sized continuous block of bits (Like Cell in Scheme)
All keywords are prepended with the @ sigil.
when inside loops there are some keywords that are just syntatical sugar for commonly used statements.
for $i range arr {
##Print arr[i+1]
// ^ could be written as the following
##Print $$next
}
@next -> arr[i+1] @previous -> arr[i-1] @first -> arr[0] @last -> arr[len(arr)-1]
Silicon is intended to be very similar to Golang in concept but more focused on app programming (front-end + UI) as opposed to systems development. It'll also have some functional programming aspects so it'll be multi-paradigm like ReasonML / OCaml. Its goals are to be simple, minimal, clean and cross-platform. It'll target JavaScript / WASM as well.
The first bit was written in Golang but I'm writing the compiler in Reason (OCaml) now.
What are the goals for your language? What are you writing your compiler / interpreter in?