Home / 2
Name Modified Size InfoDownloads / Week
Parent folder
ReadMe.txt 2026-06-15 26.6 kB
Totals: 1 Item   26.6 kB 0
Ritchie Programming Language Specification

   
Ritchie is System Programming Language with Optional High Level Feathures.
Ritchie Source File Extantion is .ken(like main.ken).
There will be no module system, no private and protected.
All is global and public like C. Syntax is like C with new Fethures.
One-Space indentation(not strict but official style guide).
Ritchie Programming Language Developed by Arshad Latti.
no variable shadowing.





Compile-Time Metaprogramming Execution(CME):

#compile.time.code
 // Executes logic strictly during compile-time resolution
#end.compile.time.code // also can #end

#compile.run.time.code
 // Shared structural utilities visible inside compile and runtime phases
#end.compile.run.time.code // also can #end

#compile.time.create.code NAME //just plain text
// Automatically drops dynamic code blocks directly back into source


example


#compile.time.code
sub say_hello()
{
write_code("\"Hello World\"");
}

sub say_verbos(bool b)
{
  sure b;
  code = text.c"""
  puts("verbos mode is active");
"""
  write_code(code);
}
#end

#compile.time.create.code HELLO say_hello();
#compile.time.create.code VERBOS(B) say_verbos(B);

sub main()
{
puts(HELLO);
VERBOS(#false#)

}

Chapter: Comments   
[1]
// single line
[2]
/* */ multi line 
[3]
#remark
// comment 1 and 2 and code all become comment
#end.remark
[3.1]
#remark name
no we can put
#end.remark
inside

#end.remark name

Preprocessor Directives

#end[.optional] // after #end is optional, like #end.if is as same #end

#header FOO_LIB
// Isolated compiler layout boundary
#end.header

#macro NAME
//like #define but multiline

#end.macro

#define 

#if.defined  VAL
 // Conditional logic block
#end.if // also can be #end

#if.not.defined SOME_VALUE

#end.if.not // also can #end

#else.if.defined

#end.else.if.define


#else.not.defined

#end.else.not.defined



//todo #macro.if #macro.else #macro.else.if #end.macro.if 

#error
#warning


#file.add "system_io.h"
#file.add "lenna_rgba.hex" // just add like text file
#file.binary core_blob, "firmware.bin" // Embeds raw image file asset cleanly


#enable WIN32 // like #define
#disable WIN32 == #macro.undefine WIN32 //like #undef

#header.import "math.ken" // all function and global data visiable 
#header.include "sdl.ken" // add once(with gaurd act like c include 

#line line_num ["filename"]// Preprocessor emit line number for compiler


Compiler Pipeline:
1.compiler time code
2.Preprocessor
3.compiler


Chapter: Data Types

  builtin index data type(index_t):
   index_t internals
   type.define int index_t;
   meta<index_t>.default = -1;

  builtin error data type(error_t):
   error_t internals
   type.define int error_t;
   meta<error_t>.default = -1;

      true, false and null:
        true 1, false 0, null 0
        we can write 0 inplace of null and false.
         void *? p = 0;// same as void *? p = null;
         bool b = 0;// same as bool b = false;
        we can write 1 inplace of true.
         bool b_val = 1;// same as bool b_val = true;
        

     Top Data Types List:  
          int, bool, index_t , error_t ,int8_t i8 ,int16_t i16 ,int32_t i32, int64_t i64
          uint, uint8_t byte_t u8 , uint16_t u16,uint32_t u32,uint64_t u64
          float, double
          char, wchar_t, 
          void,
           size_t

     endian-aware data types(Auto Bytes Order handling):
     i16le,i32le,i64le,
     i16be,i32be,i64be,
     u16le,u32le,u64le,
     u16be,u32be,u64be,
     f32le,
     f32be,

     endian examples
     i32le x = 65536;// 65536 is system endian int on need coverted to i32le
     i32be y = x;// auto convert
     u32 z = y; // convert if host system is litle endian
     z = x;// convert if host host system is big endian


Chapter: Control Flow and Loop

    if , if.not , else, else.if, switch, case, default case.else ,
    for, for.{a-z}, for.forever,  while, do, break, continue

   case.else keyword: same as default: in switch 
   
   if keyword:
    same as c if keyword and if pointer only check by it its make valid in if scope.
    if( x > y) // like c 
  
   int *? p;// optional pointer( nullable pointer)
   if(p)
   {
    // auto meta p.valid_pointer = true; in this scope

   }   




   if.not keyword: like if(!(expr))
  





   

   for keyword:
    like c 
    int i;
    for(i = 0; i < 10; i++)
     //...
   
  for.variable_name variable_name limit to one charactor like a-z.
  for.{variable name 1 char a-z} keyword: for.{1 char} max
    for.a ... for.z like for.i , for.j , for.x , for.y 
    for.i 10
     same as 
     int i;
    for(i = 0; i < 10; i++)
     

  for.forever keyword: loop
     same as 
      while(1)



Chapter: const keyword
const keyword act like C keyword const.
for function parameters, variable and pointers for readonly data access.



Chapter: auto keyword
auto keyword is optional its always enabled.
x = 10; // same as auto x = 10; // become int x = 10;
f = 3.14;//became double f = 3.14;

sub auto_example()
{
x = 10; // same as int x = 10;
// x type-locked to int
x = 3.14; // x is int as above
print(x); // 3
}

Chapter: cast Keyword 
cast.sub<T>,cast<T>,cast.copy<T>


[cast.sub example]

type.sub MouseCallback(x,y);

sub cast_sub_example(x,y)
{
void *? raw_symbol = os_get_proc_address("on_mouse_move");
sure raw_symbol; 
MouseCallback * on_move = cast.sub<MouseCallback*>(raw_symbol);
on_move(x,y);
}

Chapter: More Usefull Keywords
align_of, type_of, count_of, pack_of, size_of, offset_of

 size_of: same as sizeof in c
 count_of: return array item count.
 

Chapter: meta default
meta<T>.default = value;

builtin:
meta<int>.default = 0;
meta<float>.default = 0.0;
meta<bool>.default = false;
// builtin Richie new Types for error and index handling
meta<index_t>.default = -1;
meta<error_t>.default = -1;

      


Chapter: Default Arguments


    Default Arguments (=): Assigns static fallback constants to function parameters that are automatically filled in at the call site.
    sub foo(x = 10);

   Auto Default Arguments (skip parameter when calling function): meta<T>.default will be used.
     sub foo(x,y,z); 
     call it
     foo(); // same as foo(0,0,0);   
     foo(1);// same as foo(1,0,0);

Chapter: UFCS like Meta Compiler Methods and Fields

It like UFCS(Unified Function Call Syntax).

chaining like obj.pt.x unavailable.
get and set in on place like pt.x += 10; unavailable.
_t at end of typename is remove by default.
set_x
 and x_set both allowed.


meta<typename>.method method_name = func_name;

   // Manual mapping assignment
   sub void shift_coordinate(point *p, amount);
   meta<point>.method move = shift_coordinate;


    Dot Notation (.) and (->) : object-style method calls
      sub point_center(w,h);
      sub foo(point * p,w,h)
       {
        p.center(w,h);// same as point_center(p,w,h);
        point pt;// var 
        // auto mapping
        pt->center(w,h);//same as point_center(&pt,w,h);// if we have var we have to use ->  

      }
     
    note like p.center if no meta<point>.method center = point_center; is define Ritchie will do typename_{method_name}


point * p;
point_t * pt;
p.action();// point_action(p);
pt.action();// point_action(p); auto detect _t in at end of point_t

type framebuffer_image_t
{
 int w;
 int h;
 int pitch;// in pixels
 pixel_t * pixels;
}

meta<framebuffer_image_t>.prefix = fi;


sub fi_make_gray(framebuffer_image_t * fi);
 
//call 
fi.make_gray();


meta<T>.field,
meta<T>.get,
meta<T>.set

sub int point_get_x(point *p);
sub void point_set_x(point *p, int val);
meta<point>.field x = point_get_x, point_set_x;

sub field_example1()
{
point pt;
int current_x = pt->x; // Transpiles to: int current_x = point_get_x(&pt);
pt->x = 42; // Transpiles to: point_set_x(&pt, 42);
}

   

   


[auto mode without meta data]
typename or typename_t ( _t auto remove):
typename

typename_method_name :
pointer.method_name var->method_name

typename_set_field_name,typename_field_name_set,typename_get_field_name,typename_field_name_get :
pointer.field_name var->field_name

typename_get_at, typename_set_at:
pointer[index],variable[index]


[Prefix Overrides ( .prefix = and .prefix += )]
type framebuffer_image_t { int w; int h; int pitch; pixel_t * pixels; }

meta<framebuffer_image_t>.prefix = fi;

sub fi_make_gray(framebuffer_image_t *fi);

// Invocation
sub prefix_example(framebuffer_image_t *img)
{
img.make_gray(); // Transpiles directly to: fi_make_gray(img);
}

[ .prefix += example]
sub<T> window_set_text(T *wnd, string txt);

type button_t { HWND hwnd; }

meta<button_t>.prefix = btn;

meta<button_t>.prefix += window; // Append shared generic prefix family

sub main()
{
button_t *btn;

btn.text = "Click Me"; // Auto-resolves prefix family constraint -> window_set_text(btn, "Click Me");
}

Chapter: meta returns for multi-return
sub char *? load_file(error_t*? error);

meta<load_file>.returns error; // Maps the out-parameter pointer to the second return slot

s, err_num = load_file(); 

or
s =* load_file();// error is set to null it optional 


Chapter: literal endian
// code is written on litle endian system
#define.le MAGIC_A 0xFF00

Little-Endian (x86 / ARM)
0xFF00
Big-Endian (MIPS / Network)
0x00FF
In RAM(all system)
00 FF

//ARGB
#define GREEN "FF00FF00".hex.u32le
or
#define.le GREEN 0xFF00FF00

even at call site
source
set_pixel(x,y,"FF00FF00".hex.u32le);
and become
Little-Endian (x86 / ARM)
set_pixel(x,y,0xFF00FF00);
Big-Endian (MIPS / Network)
set_pixel(x,y,0x00FF00FF);
Physical Byte Layout (RAM / VRAM)
00 FF 00 FF




Chapter: Array Like Acccess for Types
meta<T>.set_at and meta<T>.get_at or meta<T>.array_access
[Array like access Example]
 v = lst[0];// same as lst.get_at(0);
 lst[0] = 0; // same as lst.set_at(0,0);

Chapter: meta is_valid
meta<T>.is_valid(var_name) = (expr);

meta<index_t>.is_valid(v) = (v >= 0);

sub is_valid_example_1()
{
     index_t i;
     if(i) // same as if(i >= 0)
     {
       // code
     }
    sure i; // sure can check for valid index
  }


// example 2 for is_valid
sub index_t index_of(string s, string f);
sub is_valid_example_2()
{
index_t i = index_of("a str", "str");
 if (i) // same as if (i >= 0)
  {
  print("found");
  }
}

 meta<error_t>.is_valid(v) = ( v == 0)
    same as index_t now we can use with if and sure
   

Chapter: sub keyword
default return and parameter type is int.

    keyword sub : subroutine , functions starting keyword.
      sub return_type function_name(typename parameter_name);
     sub foo(); // default return value is int
      sub void foo(x,y);// default parameter typename is int
      




    sub<T>: Declares compile-time templated function.
      sub<T> return_type function_name(T var_name);
   
     sub<T> bool same(T * a , T * b); 

sub main()
{
 x = 10;
 p = &x;
 p2 = &x;
 
 sure same<int>(p,p2); 

}

naming for sub<t> :

same<int> will become same_int
if valid pointer * used it add _valid_pointer
sub<T> genric_sub<T v);
genric_sub<int*> will become genric_sub_int_valid_pointer
if optional *? used it add _optional_pointer
genric_sub<int*?> will become genric_sub_int_optional_pointer

sub.thread:
run in thread
sub.thread void thread_function(x,y);

 

Chapter: Meta Valid and Optional Pointer 

* valid pointer(non null pointer).
*? optional pointer(can nulll).
for optional point_name:
 meta point_name.valid_pointer  = value;
like
 meta p.valid_pointer = true; 

[ Make a optional pointer to valid pointer example]
sub optional_pointer_example(int *? p)
{
// can do it yourself but its not good idea
// meta p.valid_pointer = true;// scoped, your pointing to your leg

if(p)// if keyword know its have only one p(optional pointer to handle
{
// meta p.valid_pointer = true; //scoped, your leg is safe here
//auto by if , we have know valid pointer(non null pointer)

}

}



[valid pointer example]
sub valid_pointer_example(int * out)
{
*out = 0;// nothing to worry , out is valid non null pointer
}




Chapter: sure and ensure keywords

    sure keyword: 
      1. sure variable_name
      2. sure expr

      it like sure a > b become 
           if(!(a > b))
            return;      
      3. sure optional pointer
       if pointer is not null set neta p.valid_pointer = true;



Memory allocation


sub<T> T *? alloc(size_t count);

sub<T> void free(T * p);
meta<alloc>.delete = free;


//1
p = alloc<int>(10);
sure p;
defer p;
//2
//same as 1
//Operator ( =* ) integrates sure
p =* alloc<int>(10); // =* add sure p;
defer p;
/
/3

p = ensure alloc<int>(10);
// same as 2 and add defer p;


 co thread:
 co@function_name: create thread
   work on hosted system like Windows and linux.
   enable co like (enable by default on Windows and Linux)
   system@co = create_thread
   type.sub void * thread_function_f(void * ctx);
   sub create_thread(thread_function_f function_pointer,void *? context_pointer);// how create_thread look like name it as you wish
   
  example code:
   sub void download_assets(const char* server_url, timeout_seconds);


sub main() {
    url = "https://assets.quantis.io/pack01.pkg";
    timeout = 30;

    // Fire and forget: Runs download_assets in the background immediately
    co@download_assets(url, timeout); 

    // Main thread execution continues instantly without blocking
    print("Download dispatched. Initializing game loop...");
}

Transpiler Code Generation (Lowered C Output)
 // 1. Transpiler automatically generates an argument carrier layout
typedef struct {
    const char* server_url;
    int timeout_seconds;
} _co_args_download_assets;


// 2. Transpiler generates a standard signature worker wrapper
void* _co_worker_download_assets(void* raw_payload) {
    _co_args_download_assets* args = (_co_args_download_assets*)raw_payload;
    
    // Executes your original function procedurally
    download_assets(args->server_url, args->timeout_seconds);
    
    // Cleans up the parameter carrier memory safely
    free(args);
    return NULL;
}


// 3. The lowered main function
void main() {
    const char* url = "https://assets.quantis.io/pack01.pkg";
    int timeout = 30;

    // Transpiler packs your variables into the carrier
    _co_args_download_assets* carrier = malloc(sizeof(_co_args_download_assets));
    
if(carrier){
    carrier->server_url = url;
    carrier->timeout_seconds = timeout;
    
    
    create_thread(_co_worker_download_assets,carrier);
}

    print("Download dispatched. Initializing game loop...");
}
 

create_thread  will use CreateThread on Windows and pthread_create on Linux and other system.




Chapter: defer
defer, defer.error , return.ok, defer.return

 return.ok keyword: helper for defer.error if return.ok then defer.error will not run.

 defer keyword : Schedules a cleanup expression to automatically execute across all subsequent return pathways.
       1. defer var_name
          defer var_name // same as defer delete
       2. defer expr
           defer free(p) // free memory 
           defer fclose(f) // close file

    defer.error keyword: only run if function failed
    type buffer{ void * p; size_t len; }
    sub buffer *? buffer_new(len)
    {
      buffer * r = (buffer*) malloc(size_of(buffer));
      sure r;
      defer.error free(r);
      r->p = malloc(len);
      sure r->p; // if malloc return null defer.error free(r) will run;
      r->len = len;
      // by return.ok any defer.error will be not called
      return.ok r;// return.ok make pair with defer.error for ease confusion
      
    }
  
defer.return keyword:
buffer_new function code with defer.return.
sub<T> T *? Alloc(size_t count);

sub<T> void Free(T * p);

meta<Alloc>.delete Free;

    sub buffer *? buffer_2_new(len)
    {
      r = Alloc<buffer(1);
      sure r;
      defer.return r;// r have meta defer value so defer.return work on r.
      r->p = Alloc<u8>(len);
      sure r->p; // if malloc return null defer.return Free(r) will run;
      r->len = len;//after last expr , auto return.ok r;
    }



Chapter: type keyword
type, type<T>, type.define , type.sub , type.alias , 
type.record, type.enum, type.enum<T>, .inlay , type.union.inlay, 
type.match , switch.match, type.handle

 keyword type.define is like c typedef but types not for functions.
 keyword type is like C struct keyword.
 type<T> is templated(generic type).
 keyword type.record is packed structure.
 keyword type.enum is enum and type.enum<T> with optional typename.
 keyword type.enum and type.enum<t> can have name(optional).
 keyword type.union is like C union.

 [enum examples]
    1. no name, no type , default type int, no namespace
     enum{
       FILE_SAVED // FILE_SAVED = 0
       ,FILE_NEED_SAVE // FILE_NEED_SAVE = 1
       ,FILE_IS_READ_ONLY = 10
        }
     
     used like
    int save_state = FILE_IS_READ_ONLY;
   
    2. with typename, no name , no namespace
     type.define u32 pixel_t; 
     enum<pixel_t>
       {
         COLOR_BLACK = 0xFF000000;
         COLOR_WHITE = 0xFFFFFFFF;
       }
    used like
     pixel_t pix = COLOR_BLACK;
   3. typename and name 
    enum<pixel_t> color
     {
      black = 0xFF000000;
      white = 0xFFFFFFFF;
      }
    used like
    pixel_t pix = color.black;






[keyword type.union examples]
 
    type.union dynamic_arg_u
    {
     char   ch;
     int    i;
     uint u;
     float  f;
     double d;
     char * s;
     void * p;
    }
    
   type dynamic_arg_t
    {
      int var_type;
      dynamic_arg_t var;
    }
   
   type.enum dynamic_type
   {
    var_none,
    var_char,
    var_int,
    var_uint,
    var_float,
    var_double,
    var_string,
    var_object
   }

 

   sub union_example(dynamic_arg_t * dyn)
    {
      dyn->type = dynamic_type.var_int;
      dyn->var.i = 10;
    }


   Dot Compiler Guide(DCG) .inlay:
     .inlay union_name optional_variable_name;

    type  dynamic_parameter
    {
     int pram_type;
     .inlay dynamic_arg_t pram;
     }

  sub dcg_inlay_union_example(dynamic_parameter * dyn)
   {
     dyn->pram_type = dynamic_type.var_int;
     dyn->i = 10;// same as dyn->parm.i = 10;
   }

  keyword type.union.inlay:
  type.union.inlay [optional_name] { }

    type parameter_for_dynamic_type
     { 
      int parameter_type;
      type.union.inlay
        {
         char   ch;
         int    i;
         uint u;
         float  f;
         double d;
         char * s;
         void * p;
        }
     }

   sub union_inlay_example(parameter_for_dynamic_type * pram)
   {
     pram->parameter_type = dynamic_type.var_int;
     pram->i = 10;
   }

    [keyword type.sub]
    keyword type.sub declare a function prototype. 
 
     type.sub return_type function_name(parameters);

     type.sub is act like C typedef but for function only.
     

      type.sub sub_proto_example();
      in  c 
      typedef int (*sub_proto_example)(void);


        
   [type.alias vs type.define]
   if alias a type like
   type.alias int * PINT;
   lets say we have genric function
   sub<T> alias_example(T p);
   alias_example<PINT>(p); // same as alias_example<int*>
   if we do type.define like
   type.define int response;
   alias_example<int>(i);// not same alias_example<response>(r);

[ type.match examples]

type.match WebEvent {
PageLoad,
KeyPress(u8 key),
Paste(char* text)
}

switch.match(event) {
case KeyPress(u8 k):
print("Key recorded: ", k); // 'k' is scoped locally and extracted safely
case.else:
print("Handling fallback state.");
}




Chapter: Dot Compiler Guide(DCG) 
Line Start With Dot(.)
        .align 
        .offset 
        .extern
        .register
        .volatile
        .static
        .rom
        .rom.volatile
        .data
        .data.volatile
        .inlay

    meta compiler volatile@:

   .volatile and volatile@: keep variable in ram.
              .volatile int x;
              same as 
              int x;
              volatile@x = true
       two ways to ensure variable will placed in ram.

[.offset example]
   type.record mbr_sample
      
{
   
      
    .offset 446
  
          u8 partition_type;

             .offset 510
    
              u16le boot_signature
;  
   
          }


Chapter: self keyword
self 
can used as parameter name and variable name. Work on both pointer and data structure.


self keyword: implicit field scope, used as function parameter to indicate type function is working on.
   typename * self 
   1. work only with pointer and types both
   2. self keyword can be used anywhere not just as first parameter
   3. even inside function some variable can be named self.

  type recta { int x; int y; int w; int h;}
  
    
   sub recta_make_half_size(recta * self)
   {
    w /= 2;//  same as self->w /= 2;
    h /= 2;// same as self->h /= 2;
   }

  sub recta_memset(val,recta * self)
   {
    x = val;
    y = val;
    w = val;
    h = val;
   }

Chapter: new and delete keywords
meta<T>.delete and meta<T>.new is use bye delete and new.

keywords new : 
 use meta compiler meta<T>.new = typename_new;
 let say we 
  type point
  { 
    int x;
    int y;
  }     
 sub point *? point_new();
 sub void point_delete(point * p);

 meta<point>.new = point_new;
 meta<point>.delete = point_delete;

 can call using
 sub example_of_new()
{
  p = new point();
  sure p; //check for null pointer if its null return from function
  defer p;// same as defer delete p; defer is delete aware
}





keyword delete:
     meta compiler meta<T>.delete = typename_delete;

example for new and delete
type mem
{
void * ptr;
int len;
}

sub mem *? mem_new(size);
sub void mem_delete(mem * m);

meta<mem>.new = mem_new;
meta<mem>.delete = mem_delete;

sub example_of_new_delete()
{
  m = new mem(4096);
  sure m;
  defer m; // same as defer delete m;  m is mem and its support delete so defer dectect that
  
  // delete m; // auto by defer at every exit point  
}




 
Chapter: Raw Bits Bytes Access(R3A)
[Bytes]

cast.bytes(variable_name) ,
cast.bytes(*pointer_name) ,
cast.pointer.bytes(pointer_name)

[Bits]
cast.bits(variable_name),
cast.bits(*pointer_name),
cast.pointer.bits(pointer_name)

[raw type access]
cast.as<typename>(variable_name),
cast.as<typename>(*pointer_name),
cast.pointer.as<typename>(pointer_name)

[Bytes Get Set Example]
int x_num;
u = cast.bytes(x_num)[0];// read x_num first byte
cast.bytes(x_num)[1] = 0;// write 2nd byte

[Byte Read Writing via Pointer Example]
sub foo(int * p)
{
 u = cast.bytes(*p)[0];// read 1st data byte
}

[Bits Get Set Example]
sub bits_get_set_example()
{
 int x;
 cast.bits(x)[0] = 0; // set bit 
 b = cast.bits(x)[0]; // get bit
}
[Bits via Pointer Example]
sub bit_via_pointer_example(u32 * p)
{
  b = cast.bits(*p)[0];// get bit
  cast.bits(*p)[0] = 1;// set bit

}

[raw variable and pointer to type and get set example]
type r_t_loc { u8 x; u8 y; };
sub raw_type_example()
{
 u32 u;
 cast.as<loc>(u)[0].x = 128; // set
 v = cast.as<loc>(u).y;// get
  
 cast.as<u16>(u)[1] = 0xffff;// set
}
//raw type pointer example
sub raw_type_example_ptr(u64 * p)
{
 cast.as<loc>(*p)[0].w = 10;//set
 h = cast.as<loc>(*p).h;// get 
}






Chapter: Context Function Pointer (CFP)
 //declare a function prototype
type.sub cfp_proto(i,double *cxt);

sub function_with_context(i,double * context);

sub cfp_example(function<cfp_proto,double*> * f)
{
 f(13,f.context);
}

sub main()
{
 d = 3.14;
 f = cast.function<cfp_proto,double*>(function_with_context,&d);
 cfp_example(f);
}
-----------
type.sub<T> void free_proto(T * p);

sub<T> void free_this(free_proto<T> *f, T * p);

sub void free_int(int * p);
free_proto<int> * f = free_int;
 
 


Chapter: Wide Pointer

    typename[] var_name;
    name = cast.wide<T>(raw_buffer,count)
    count_of(wide_pointer)  
    
// Wrapping standard dynamic heap segments
int* raw_buffer = (int*)malloc(sizeof(int) * 200);
int[] wide_buf = cast.wide<int>(raw_buffer, 200); 
or( auto is always on)
wide_buf = cast.wide<int>(raw_buffer, 200); // 

type __WidePointer_Internal {
typename * data; 
size_t count;
}

example

// Wide pointer used as a parameter and a return type
sub int[] filter_positive_values(int[] input_data) {
size_t total = count_of(input_data);
if (total == 0) return input_data;
// Boundary validations are implicitly active during execution
for (size_t i = 0; i < total; i++) {
if (input_data[i] < 0) {
input_data[i] = 0;
}
}
return input_data;
}

for.each keyword support wide pointer:
  sub sum_ints(int[] vals)
   {
     int r = 0;
     
     for.each(v in vals)
       {
        r += v;
       }

     return r;
   }
[Implicit Wide-to-Raw Decay]
sub void decay_to_raw_example(u8* buffer, size_t size);
sub decay_example(u8[] w_ptr)
{

// Native invocation passes the wide structure seamlessly
 decay_to_raw_example(w_ptr, count_of(w_ptr));


  w_ptr++; // COMPILE ERROR: Mutating arithmetic forbidden on wide pointers
 w_ptr += 4; // COMPILE ERROR: Mutating arithmetic forbidden on wide pointers 
 
 // Explicitly narrow the view window safely
 sub_view = cast.wide<u8>(w_ptr + 20, 80);
}

Void Restrictions cast.wide<void>(...)
bad_ptr = cast.wide<void>(malloc_ptr, 512); // COMPILE ERROR: void wide pointers are illegal


empty wide pointers have  NULL address and 0 length.
sub wide_pointer_empty_example(u8[] wp)
{
 if(wp) // same as if(count_of(wp)) // both check length
 {
  // yep, its have some count
 }
}


Raw to Wide Promotion
w = cast.wide<T>(ptr,count);
Wide to Raw Decay
T* raw = w;
Length Inspection
count_of(w)
Mutating Arithmetic is banned
w++; or w += n;// error
Sub-Slicing Range
cast.wide<T>(w + offset,size);// ok w + offset don't change w 







Source: ReadMe.txt, updated 2026-06-15