Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ref int x := 5;
- int *x = malloc(sizeof(*x));
- *x = 5;
- (int *)x = 5;
- int x_data;
- int *x = &x_data;
- *(int *)x = 5;
- #include <stdio.h>
- #include <stdlib.h>
- main(){
- auto int*** crrri;
- crrri=(int***)malloc(sizeof(int**));
- *crrri=(int**)malloc(sizeof(int*));
- **crrri=(int*)malloc(sizeof(int));
- ***crrri=255; /* coder to explicitly work out how many times dereference */
- printf("%5.1fn",(float)***crrri); /* Again deref is muilt-explicit */
- }
- 255.0
- #!/usr/bin/a68g --script #
- # -*- coding: utf-8 -*- #
- LOC REF REF REF INT crrri;
- REF REF REF REF INT(crrri):=HEAP REF REF INT;
- REF REF REF INT(crrri):=HEAP REF INT;
- REF REF INT(crrri):=HEAP INT;
- REF INT(crrri):=255; # targeted dereferencing (3x) depending on contect #
- printf(($"example meek coercion:"g(-5,1)l$,REAL(crrri)));
- PROC VOID raise exception = end; # Implicitly cast a "GO TO" to a PROC #
- # Soft: deprocedure a PROC to a VALUE #
- printf(($"Soft:"gl$,random)); # Implicit Coercion #
- printf(($"Soft:"gl$,REAL(random))); # Explicitly cast/deprocedure #
- # Weak: dereference pointer chain to a "name" (LHS in C lingo) #
- COMPL compl:= 0;
- re OF compl := crrri; # Implicit Coercion #
- REF REAL(re OF compl) := crrri; # Explicitly cast/dereference #
- printf(($"Weak:"g(-0,4)g(7,4)"i"l$,compl));
- # Meek: dereference to a value #
- printf(($"Meek:"gl$,sin(crrri))); # Implicit Coercion #
- printf(($"Meek:"gl$,sin(REAL(crrri)))); # Explicitly cast/dereference #
- # Firm: unite to a UNION #
- MODE IRC=UNION(INT,REAL,COMPL);
- OP SIN = (IRC z)IRC: (z|(INT i):sin(i),(REAL r):sin(r),(COMPL z):complex sin(z));
- printf(($"Firm:"gl$,SIN 1)); # Implicit Coercion #
- printf(($"Firm:"gl$,SIN IRC(1))); # Explicitly cast/unite #
- # Strong: widen to higher precision OR to an array #
- FLEX [0]BOOL bool array := BIN crrri; # Implicit Coercion #
- bool array := []BOOL(BIN crrri); # Explicitly cast/widen #
- printf(($"Strong:"$,$g$,bool array,$l$));
- end: SKIP
- example meek coercion:255.0
- Soft:+2.11679610884246e -1
- Soft:+4.01945464342605e -1
- Weak:255.0000+0.0000i
- Meek:-5.06391634924491e -1
- Meek:-5.06391634924491e -1
- Firm:+8.41470984807897e -1
- Firm:+8.41470984807897e -1
- Strong:FFFFFFFFFFFFFFFFFFFFFFFFTTTTTTTT
Add Comment
Please, Sign In to add comment