CPoint
Jump to navigation
Jump to search
CPoint also known as C* is a language based solely around pointers. The goal is to isolate the aspects of pointers that make them so great in other languages like C. These apsects include their flexibility, intuitiveness, and legibility.
Commands
In `C*`, all the functionality is done through pointers and there associated types. There are a collection of different pointers that have side effects when you dereference them. It is through these side effects that you can get the functionality of any other language.
Name | Syntax | Description |
---|---|---|
Normal | int *value; |
No side effect |
Increment | int +value; |
Incriments the variable that is pointed too. |
Decrement | int -value; |
Decriment the variable that is pointed too. |
Jump pointer | int value^; |
Sets the program counter to the address value. Effectively starts running from the variable pointed too. |
Ternary | int value?; | Will only dereference if the value before it is 0. |
Read pointer | int >>value; |
Read a value from stdin. Doesn't use the value that it is initialized with. |
Write pointer | int <<value; |
Write the value it was initialized with to stdout. It will return a normal dereference which in most situations won't be helpful. |
Misc Notes
- A program consists of a series of variable declarations. Not every variable needs to be initialized however the only valid expression is pointer dereferencing.
- Every pointer is a 32 bit signed integer.
- Address values reference consective integers (as opposed to the bits inside an integer). This makes it easy to use address for miscellaneous values. For example, since numeric constants like
5
are not allowed, you can just take the reference of the sixth variable. - The program counter corresponds to the address of the variable that is being processed.
- Variables without an initialization are set to 0.
- Variables that take the address of another variable (
int *value = &ptr;
) are initialized before the program starts. - De-referencing
0
will cause the program to halt.
Example Programs
Hello World
int *null; int <<char1 = &H; int <<char2 = &e; int <<char3 = &l; int <<char4 = &l; int <<char5 = &o; int <<char6 = &space; int <<<<<<<<<<rest = &W; int *r1 = *char1; int *r2 = *char2; int *r3 = *char3; int *r4 = *char4; int *r5 = *char5; int *r6 = *char6; int *everything = *****rest; int *end = *null; int *_17; int *_18; int *_19; int *_20; int *_21; int *_22; int *_23; int *_24; int *_25; int *_26; int *_27; int *_28; int *_29; int *_30; int *_31; int *_32; int *space; int *_34; int *_35; int *_36; int *_37; int *_38; int *_39; int *_40; int *_41; int *_42; int *_43; int *_44; int *_45; int *_46; int *_47; int *_48; int *_49; int *_50; int *_51; int *_52; int *_53; int *_54; int *_55; int *_56; int *_57; int *_58; int *_59; int *_60; int *_61; int *_62; int *_63; int *_64; int *_65; int *_66; int *_67; int *_68; int *_69; int *_70; int *_71; int *_72; int *H; int *_74; int *_75; int *_76; int *_77; int *_78; int *_79; int *_80; int *_81; int *_82; int *_83; int *_84; int *_85; int *_86; int *_87; int *W = &o; int *_89; int *_90; int *_91; int *_92; int *_93; int *_94; int *_95; int *_96; int *_97; int *_98; int *_99; int *_100; int *d; int *e; int *_103; int *_104; int *_105; int *_106; int *_107; int *_108; int *l = &d; int *_110; int *_111; int *o = &r; int *_113; int *_114; int *r = &l; int *_116;
Fibonacci sequence
int *null = &null; int *one; // Read char int >>get_char; int *fib_count = *get_char; //global tools int -dec_fib_count = &fib_count; int *exit = &null; int <<print_one = &one; int test_base_case_1?^ = &end_base_case_1; int *is_zero = fib_count; int _t13 = **test_base_case_1; int base_case_1; int _t16 = *print_one; int _exit1 = *null; int end_base_case_1 = &base_case_1; int test_base_case_2?^ = &end_base_case_2; int *is_zero_2 = *dec_fib_count; int _t22 = **test_base_case_2; int base_case_2; int _t24 = *print_one; int _exit2 = *null; int end_base_case_2 = &base_case_2; int fib_1 = &one; int fib_2 = &one; int +inc_fib_1 = &fib_1; int -dec_fib_2 = &fib_2; int +inc_fib_2 = &fib_2; int <<*print_fib_1 = &fib_1; int *loop_start = &loop_end; int loop_jmp?^ = &loop_start; int fib_1_copy = fib_1; int -dec_fib_1_copy = &fib_1_copy; int *first_add = &first_add_end; int first_add_jmp?^ = &first_add; int _t39 = *inc_fib_1; int _t40 = *dec_fib_2; int _t41 = **first_add_jmp; int *first_add_end; int *copy_1 = ©_1_end; int copy_1_jmp?^ = ©_1; int _t50 = *inc_fib_2; int _t51 = *dec_fib_1_copy; int _t52 = **copy_1_jmp; int *copy_1_end; int *t56 = *dec_fib_count; int *t57 = **loop_jmp; int loop_end; int _t58 = **print_fib_1;