Author Topic: Add sigil to all compile-time functions.  (Read 3139 times)

lerno

  • Full Member
  • ***
  • Posts: 247
    • View Profile
Add sigil to all compile-time functions.
« on: November 05, 2018, 12:15:11 AM »
Compile time resolution is important for a lot of functionality. Unfortunately, adding keywords for them pollutes the keyword space AND makes it harder at a glance to tell compile-time directives from runtime ones.

C2 already adds attributes using the @(...) syntax. There are roughly the following symbols available:

@ $ # ยด ~ ' `

My proposal is that we use the @ prefix, but I don't have a really strong opinion. Here are a few code samples:

Code: [Select]
@foo();       // expand macro foo

@sizeof(i32); // currently "sizeof"

@typeof(a);   // return the type of a

@sizeof(@typeof(a)); // the size of a

func i32 do_something() @(inline)
 

Code: [Select]
$foo();       // expand macro foo

$sizeof(i32); // currently "sizeof"

$typeof(a);   // return the type of a

$sizeof($typeof(a)); // the size of a

func i32 do_something() @(inline)
 

Code: [Select]
#foo();       // expand macro foo

#sizeof(i32); // currently "sizeof"

#typeof(a);   // return the type of a

#sizeof(#typeof(a)); // the size of a

func i32 do_something() @(inline)
 

Code: [Select]
`foo();       // expand macro foo

`sizeof(i32); // currently "sizeof"

`typeof(a);   // return the type of a

`sizeof(`typeof(a)); // the size of a

func i32 do_something() @(inline)
 


Code: [Select]
~foo();       // expand macro foo

~sizeof(i32); // currently "sizeof"

~typeof(a);   // return the type of a

~sizeof(~typeof(a)); // the size of a

func i32 do_something() @(inline)
 

I think that nesting @ is a bit ugly looking though. Opinions?