Skip to content

A small syntax extension for the programming language C via preprocessor

License

Notifications You must be signed in to change notification settings

sparber/CComprehensiveDatatypes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CComprehensiveDatatypes

Syntax Extension for the Programming Language C

The idea is that if there are more possible allocations for one variable – referring a concrete context - you declare the variable as comprehensive and pretend there is only one possible allocation.

The paragraph sign declares a variable as comprehensive

int § a;

The initialization of such a variable happens by calling a generator:

int § a = factors(100);

A generator’s objective is to calculate all possible solutions for a given problem. The factors(int) generator could be defined like this:

int factors(int number) generator {
    int factor = 2;
    while (factor <= number) {
        while (number % factor == 0) {
            yield factor;
            number /= factor;
        }
    factor++;
    }
}

The split operator | (vertical bar) is for processing a comprehensive variable:

void main() {
    int § compr = factors(100);
    int factor = |compr;
    printf("%d;", factor);
}

or in short:

void main() {
    printf("%d;", |factors(100));
}

This produces the output "2;2;5;5;".

The split operator defines an implicit loop, iterating over all the values represented by the consecutive comprehensive variable. The loop starts at the position of the split operator, reaching till the end of the current scope.

About

A small syntax extension for the programming language C via preprocessor

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published