Tlon
Tlon copied to clipboard
The Tlön programming language.
The Tlön programming language.
Tlön is a programming language transpiled into Modern C++. These are the key goals:
- Add features which C++ is missing.
- Throw out all the legacy crap that's been dragged into C++ over the years.
- Also, just simplify things.
- Provide a sensible API over Standard Library/STL.
- Other lofty goals :)
For a more lively demonstration, watch this video.
The following is an approximate featureset with explanations why those features are in there.
Front End
- Two-step front-end implementation
- Make use of non-keyboard symbols (e.g., subscript/superscript).
- Later: a flexible editor.
- No semicolons (they can be used for something else).
- No inappropriate symbols:
-is not subtraction,*is not multiplication, etc. This prevents the subversion of well-defined mathematical symbols. - Bitwise operators strictly textual (
xor), no operator symbols. Avoids the confusion between&&and&etc. %means%, i.e.5%means0.05. Operatorsmodandremused instead.- Minute/second marks
"'cannot be used for string or characters. <or>cannot be used for anything other than less-that/greater-than.
Basic Operations and Control Flow
- Definitions via
:=for non-constant and≝(or≡) for constants. (WIP) =used as comparison operator, also valid in mutual comparisonsif (a = b = c)- Assignment via
->and<-(both ways). This helps readability in some cases. - Assignment can cluster (
x,y <- 0,x -> y,z) and daisy-chain (x -> y -> z) - JAI's
delayfor executing code at the end of scope.
Identifiers/Variables
- Extended symbol range allows identifiers with printable non-numeric, non-syntax letters.
- Access modifier prefix?
-private, #protected, +public. - Forced initial values (zeros for numerics,
0for bits). Principle of least surprise.
Namespaces
- Namespace declarations do not 'cause' a scope, content not wrapped in
{}. This avoids a 1-tab indentation of everything you write and in 99% is a meaningless idea. - Multipart declarations are permitted:
namespace Foo.Bar. Avoids insanity likenamespace Foo { namespace Bar { .... - Fused namespace-and-class declaration. Writing
class Foo.Barcreates namespaceFooand treats all subsequence input as pertaining to classBar, unless... - Fused namespace-and-inner-class declaration. If you must. Writing
class Foo.Bar.Bazwhere a classBaralready exists in namespaceFoodoes, you guessed it, an inner classBazthat's declared insideBar.
Types
- All types inherit from
tlön::objectwhose interface containsequals(),hash_code()andstr()(just like C#). - Interfaces (a la C#/Java).
- Can feature property definitions (like C#).
- Virtual destructor added by default.
- Virtual dispatch-centric (visitor) member?
- Global members not allowed
Reflection
- All types support reflection by including a
statictable of reflection-based info. - Reflection is intended to work as it does in C#, i.e., an ability to inspect a type's properties & methods.
- Reflection is intended to provide
invoke()functionality.
Functions
add := (a,b:i32 := 0) => a+b-- argument clustering, default value, noreturnstatement and return type inferencing.- Capture modes indicated by subscript? E.g.,
add_five := x => twoᵥ + threeᵣ. - Things are passed and stored by reference by default;
Fields
- The concept of a 'field' does not exist in Tlön. Period.
Properties
- Expandable from an existing field declaration, e.g.
x,y := 0becomesx,y := 0 with get := xx and set := it -> xx. - Auto-properties
x := 0 with get and set. - Bindable properties, e.g.,
x =:= yensuresxis always set toyvia an atomic change. Implies construction of critical sections.
Events (tentative)
- TODO; most likely based on
boost::signal<>
Embedded Features
These are some features that will be baked into the system:
- Database system: most likely a direct-to-metal interface for some commercial database system (e.g., MongoDB). Think Slang/SecDB.
- Dependency injection: given that we have reflection, DI is going to be baked in and used everywhere.