View Code? Open in Web Editor
NEW
A programming language implementation in Go.
License: Apache License 2.0
comet's Introduction
Hi there, I'm Mehdi welcome to my profile.
I am a Software Engineer, Living in London, and a Huge Rust and Go enthusiast.
Mostly interested in projects involving (but not limited to) Compilers, Programming languages, Developer tools ...
I want to contribute more to open source projects (other than the ones that I create), and upload more educational videos and live streams to Youtube and hopefully blog more regularly.
I am pationate about teaching people what I learned, So if you have a project involving teaching people new things, feel free to reach out.
comet's People
Contributors
comet's Issues
I got a panic after using toString(anArray)
, because the builtin function toString
is not supported for CometArray
>> var cc = [1 , 2 , 3 ]
CometNop
>> cc
[CometInt (1 ), CometInt (2 ), CometInt (3 )]
>> println (cc )
& {3 [0xc0001020b0 0xc0001020b8 0xc0001020c0 ]}
CometNop
>> toString (cc )
panic : All types should have been exhausted ! !
goroutine 1 [running ]:
github .com / chermehdi / comet / std .ToString (0x667a58 , 0xc0001042a0 , 0x1 )
I think, We have to implement two functions to represent objects as strings, for example:
A debug function should return: CometArray[CometInt(1), CometInt(2), CometInt(3)]
The toString
function should return just [1, 2, 3]
Comet only considers numbers to only be represented in decimal format, which is not realistic in a programming language.
We expect Comet to be able to lex and parse numbers of binary, hex, octal format as well:
var a = 0xcafebabe
var b = 0b10100000
var c = 012
I tried this:
and it works, it erase old value of a
instead of returning a CometError
.
We have to fix this and I think, We must implement something to not allowing variable shadowing either, it's a source of bugs.
I tried printf("Hi\n")
in the REPL and the result was Hi\n%!(EXTRA []interface {}=[])CometNop
.
So, the issues are:
printf does not interpret special characters like \t
or \n
.
if we print something without other arguments, printf print the extra empty []CometObject that was intended to be full of other arguments.
Built-in types need better toString representation for debugging purposes.
Values and especially functions only show the type, we want something that shows the type signature as well.
Comet should provide a mechanism for better error reporting, this should be accomplished in multiple steps:
Make all the current error messages contain as much information as available / needed.
Make a dictionary of all the available errors and give them numbers for future pointers in the docs.
Print spans for where the error happened.
I tried this:
// variable 'a' is not declared before
a = 50
and it return CometInt(50)
instead of an error.
I tried that:
>> println
Comet error :
Identifier (println ) is not bounded to any value , have you tried declaring it ?
>> var println = 5
CometNop
>> println
CometInt (5 )
>> println ("Hello, World!" )
Hello , World !
CometNop
As a Python developer, I'm expecting that:
>> println
< func builtins .println >
They are two options:
Let the developer overwrite builtins functions like user's functions:
>> func add (n ) {2 * n }
< func add (n )>
>> add = 70
CometInt (70 )
Make builtins functions reserved keywords