adeptlanguage / adept Goto Github PK
View Code? Open in Web Editor NEWThe Adept Programming Language
License: GNU General Public License v3.0
The Adept Programming Language
License: GNU General Public License v3.0
func msg(message String)
{
print(message)
}
alias echo = msg
func main()
}
echo("hello")
}
@IsaacShelton What do you think about that?
Something like this:
const PI = 3.14159256
code:
import basics
import "sys/cmath.adept"
func main(argc int, argv **ubyte)
{
print(sin(30))
}
error:
file.adept:6:11: Undeclared function sin(int)!
6| print(sin(30))
^^^
Potential Candidates:
sin(double) double
Change const a = 0
to define a = 0
in order to avoid confusion with const a int = 0
code:
import basics
func main()
{
i int = 0
i-- // i -= 1 also not works
print(i)
}
result:
4294967295
should be:
-1
The ability to embed Adept would be nice in the future, when it's in a more usable state.
@IsaacShelton Add something like -l
to Adept to allow linking Adept shared libraries. I created repository that tells about creating library lib.a
in C, can you tell me how to do the same thing in Adept:
Undefined symbols for architecture x86_64:
"_repl_execute", referenced from:
_compiler_repl in compiler.o
"_repl_free", referenced from:
_compiler_repl in compiler.o
"_repl_helper_sanitize", referenced from:
_compiler_repl in compiler.o
"_repl_init", referenced from:
_compiler_repl in compiler.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [bin/adept] Error 1
@IsaacShelton I think #pragma
should be a meta directive.
code:
import basics
func main(argc int, argv **ubyte)
{
print(argc, argv)
}
error:
$ ./file argument
2
ERROR: print(...) got unknown type **ubyte
@IsaacShelton I think it will be better if there will be -I
for import directory, -l
for linking Adept .a
files to Adept and -L
for library directory of Adept .a
files.
Question: Does Adept supports linking C libraries like libreadline.1.a
and others libraries for C?
When you'll release documentation for Adept? (I really want to learn Adept.)
Is there any way to read command-line arguments like in C?
int main(int argc, char *argv[]) { ... }
@IsaacShelton For what .
symbol is used in Adept?
I think that if you want to write documentation for Adept, you can do this in Markdown style in docs/*.md
or GitHub wiki (not in PDF, like for Adept 2.3). What do you think about that?
NOTE: I think that documentation in Markdown is better that PDF documentation because of text styling.
namespace example_namespace {
func msg(text String) {
print(text)
}
}
func main()
{
example_namespace::msg("Hello, world!")
}
or:
namespace example_namespace {
func msg(text String) {
print(text)
}
}
using namespace example_namespace
func main()
{
msg("Hello, world!")
}
code:
namespace io {
foreign printf(in *ubyte, in ...) int
}
func main() {
io\printf('Hello, world!\n')
}
result:
Undefined symbols for architecture x86_64:
"_io\printf", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
EXTERNAL ERROR: link command failed
gcc "main.o" -o "main"
code:
import basics
func main(argc int, argv **ubyte)
{
printf("%s", 5) // should call a warning
}
compilation:
Compiler does not says anything about this warning.
$ ./adept file.adept
... returns nothing
$
execution:
Only on the execution step.
$ ./file
WARNING: vsprintf(*String, String, VariadicArray) expected *ubyte value for %s, got 'int' instead
zsh: segmentation fault ./file
I don't have a full idea yet of how to implement this, but the goal is to have the following:
arr *int = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
arr 10 int = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
arr <int> Array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
arr <int> List = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
I'm thinking this will probably require some built-in type kind of like std::initializer_list
in C++.
I found information about decrementing unsigned int 0:
In C:
unsigned int i = 0;
i--;
printf("%d", i); // -1
printf("%u", i); // 4294967295
NOTE: Unsigned integers have well-defined behaviour for all arithmetic operations; specifically, they implement "artithmetic modulo 2^N", where N is the number of value bits in the type. So -1 is in fact 2^N − 1
In Adept:
i uint = 0
i--
print(i)
Returns 4294967295
@IsaacShelton I have changed this syntax to be used as default and I detected that you made :
work not only for declaring variables. I mean that if make :
default, then you should use :
every time you type data type:
num : int = 0
printf(num as : int) // must be num as int
If not, it won't compile (if it will be default syntax)
P.S. I think this happens because you added :
to the parse_type()
and now every time you want to write type you should write :
before it.
Also after this syntax, I can't correctly write this string (I do not know where I should put :
):
struct <$T> PolymorphicStructName (field1 $T, field2 <$T> AnotherType)
This not works:
<$T> PolymorphicStructName :: struct(field1 : $T, field2 : <$T> AnotherType)
@IsaacShelton I know I was already opening this issue, I just thought that if you have some free time, it would be cool if this was added.
main :: func() : int {
asm {
"mov eax, ebx",
"push eax"
}
return 0
}
P.S. I think interactions with a low-level language such as assembler are useful for deep development.
I have an idea that you might not like, but I would like to add it. The point is that the compiler creates a binnary file with the same name as the source file itself, but if the user wants to change this (without using the -o
option), you can add a special meta directive at the beginning of source file (excluding libraries)
main.adept:
#program hello
#import <basics>
func main() {
print("hello")
}
adept main.adept # will output binary with
hello
filename
If you don't want to add it (in fact, it's really a useless function), then tell me how to add it, I would like to create a custom Adept version for myself with this option.
@IsaacShelton Why complicate the use of sizeof
? Why not combine sizeof
and sizeof value
?
I think it will be better if it'll looks like:
sizeof(value)
sizeof(type)
// or
sizeof value
sizeof type
@IsaacShelton After you made ::
and :
by default you can remove pragmas for enabling this syntax.
@IsaacShelton Have you planned to support this syntax:
repeat (10) print(idx)
// but if one more action:
repeat (10) {
print(idx)
}
for if
, for
, repeat
and etc.
NOTE: Like in C
I can’t understand how namespaces work, can you write me detailed documentation for creating, using and calling namespaces.
Thanks
code:
import basics
#define SAS //define sas
func main()
{
#if SAS
#error "sas" // should show error
#end
printf("Hello, world!\n")
}
result:
successful compilation without errors
my_constant :: const = value
my_alias :: alias = variable
(for functions this syntax is already exist)Compilation completed, but link failed.
ld: library not found for -lLLVMTestingSupport
OS: macOS
CPU: x86_64
LLVM: 7.0.0 (build)
@IsaacShelton I faced this bug:
code:
import basics
func main()
{
#warning "t"
}
compilation:
main.adept:5:5: main.adept:5:5: t
5| #warning "t"
^^^^^^^^
Allow #import <basics>
for standart library (placed in 2.x
) and #import "myfile"
for local libs. Or if you do not want to add this, just say me what I should modify in Adept to allow this import (I just want to use it, this type of import is more comfortable for me).
Objective-C:
#import <Foundation/Foundation.h>
@IsaacShelton Have you planned to replace gcc
with GNU link editor ld
for linking Adept binaries? Why Adept uses gcc
for linking instead of ld
?
I think that warnings should display fragment of code like errors.
Also updating #warning
for showing line:char and fragment of code like #error
.
@IsaacShelton Like
func main()
{
static variable int = 3
}
and for new syntax:
main :: func()
{
variable :: static : int = 3
}
@IsaacShelton What do you think about this?
[improve] Allow for variadic and varargs (without indirectly forcing it)
func alias echo(..) => print
func alias strictPrintf(*ubyte, ...) => printf
[bug] Also this should compile, but doesn't:
import basics
func print(a int){
a = 10
}
func alias echo() => newline
func alias echo(String) => print
func alias echo(int) => print
func main {
echo("Hello World")
echo()
echo("This is a test")
echo(12345)
}
func echo(value int){
print(toString(value).reversed())
}
It should prefer the function named echo
over the function alias, but it fails to compile.
namespace my_namespace { }
/ my_namespace :: namespace { }
using namespace my_namespace
namespace my_namespace {
func my_function() { }
}
func main {
my_namespace\my_function() // after using namespace, just my_function()
}
And for new-style syntax:
my_namespace :: namespace {
my_function :: func() { }
}
main :: func {
my_namespace\my_function() // after using namespace, just my_function()
}
NOTE: For details see #36
I have updated AdeptImport and changed all old-style declarations to new and got undeclared variable errors.
If change old-style const to new style const in libraries, then it will not work:
EOF == (-1)
changed to
const EOF = (-1)
and got this error:
cstdio.adept:147:30: Undeclared variable 'EOF'!
147| if c == 0x0A || c == EOF, break
^^^
I do not know why it works like this, maybe you can explain me why this happens.
I have a lot of issues about printing some types such as **ubyte
.
I just trying to print argv
and got the following error:
code:
import basics
import "sys/cmath.adept"
func main(argc int, argv **ubyte)
{
print(argc, argv)
}
errors:
file.adept:6:5: Undeclared function print(int, **ubyte)!
6| print(argc, argv)
^^^^^
Potential Candidates:
print(String) void
print($T~__number__) void
I know this is a lot of work, but also I think it will be better if you allow printing all data types.
import VariadicArray
import 'sys/cstdio.adept'
struct Dummy ()
func main {
dummy Dummy
printf('sum = %d\n', dummy.sumEmUp(1, 2, 3, 4, 5))
}
func sumEmUp(this *Dummy, integers ...) int {
printf('%p\n', integers.items)
printf('%p\n', integers.next)
printf('%d\n', integers.length as int)
printf('%d\n', integers.index as int)
printf('%p\n', integers.types)
sum int = 0
while integers.hasNext() {
if integers.types[integers.index] != typeinfo int {
printf('ERROR: sumEmUp() got non-int value!\n')
return 0
}
x int = integers.readInt()
printf('Got value: %d\n', x)
sum += x
}
return sum
}
Arguments are not being packaged into a VariadicArray
before being passed
@IsaacShelton -e
option analog to #pragma entry_point
like gcc -e
.
@IsaacShelton #set
is used to create a macro and write something to it, #define
just to define macro.
@IsaacShelton I think error and warning messages should looks like this (not fully red or yellow):
I know how to change them, but one part in your code I can't understand, I do not know why you done this for showing error messages:
All other parts of code don't use memcpy
for showing error messages, but this piece of code does, why?
@IsaacShelton Where the stdlib placed in system (windows/linux)?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.