Guest User

Untitled

a guest
Nov 15th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. ref int x := 5;
  2.  
  3. int *x = malloc(sizeof(*x));
  4. *x = 5;
  5.  
  6. (int *)x = 5;
  7.  
  8. int x_data;
  9. int *x = &x_data;
  10. *(int *)x = 5;
  11.  
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14.  
  15. main(){
  16. auto int*** crrri;
  17. crrri=(int***)malloc(sizeof(int**));
  18. *crrri=(int**)malloc(sizeof(int*));
  19. **crrri=(int*)malloc(sizeof(int));
  20. ***crrri=255; /* coder to explicitly work out how many times dereference */
  21. printf("%5.1fn",(float)***crrri); /* Again deref is muilt-explicit */
  22. }
  23.  
  24. 255.0
  25.  
  26. #!/usr/bin/a68g --script #
  27. # -*- coding: utf-8 -*- #
  28.  
  29. LOC REF REF REF INT crrri;
  30. REF REF REF REF INT(crrri):=HEAP REF REF INT;
  31. REF REF REF INT(crrri):=HEAP REF INT;
  32. REF REF INT(crrri):=HEAP INT;
  33. REF INT(crrri):=255; # targeted dereferencing (3x) depending on contect #
  34. printf(($"example meek coercion:"g(-5,1)l$,REAL(crrri)));
  35.  
  36. PROC VOID raise exception = end; # Implicitly cast a "GO TO" to a PROC #
  37.  
  38. # Soft: deprocedure a PROC to a VALUE #
  39. printf(($"Soft:"gl$,random)); # Implicit Coercion #
  40. printf(($"Soft:"gl$,REAL(random))); # Explicitly cast/deprocedure #
  41.  
  42. # Weak: dereference pointer chain to a "name" (LHS in C lingo) #
  43. COMPL compl:= 0;
  44. re OF compl := crrri; # Implicit Coercion #
  45. REF REAL(re OF compl) := crrri; # Explicitly cast/dereference #
  46. printf(($"Weak:"g(-0,4)g(7,4)"i"l$,compl));
  47.  
  48. # Meek: dereference to a value #
  49. printf(($"Meek:"gl$,sin(crrri))); # Implicit Coercion #
  50. printf(($"Meek:"gl$,sin(REAL(crrri)))); # Explicitly cast/dereference #
  51.  
  52. # Firm: unite to a UNION #
  53. MODE IRC=UNION(INT,REAL,COMPL);
  54. OP SIN = (IRC z)IRC: (z|(INT i):sin(i),(REAL r):sin(r),(COMPL z):complex sin(z));
  55. printf(($"Firm:"gl$,SIN 1)); # Implicit Coercion #
  56. printf(($"Firm:"gl$,SIN IRC(1))); # Explicitly cast/unite #
  57.  
  58. # Strong: widen to higher precision OR to an array #
  59. FLEX [0]BOOL bool array := BIN crrri; # Implicit Coercion #
  60. bool array := []BOOL(BIN crrri); # Explicitly cast/widen #
  61. printf(($"Strong:"$,$g$,bool array,$l$));
  62.  
  63. end: SKIP
  64.  
  65. example meek coercion:255.0
  66. Soft:+2.11679610884246e -1
  67. Soft:+4.01945464342605e -1
  68. Weak:255.0000+0.0000i
  69. Meek:-5.06391634924491e -1
  70. Meek:-5.06391634924491e -1
  71. Firm:+8.41470984807897e -1
  72. Firm:+8.41470984807897e -1
  73. Strong:FFFFFFFFFFFFFFFFFFFFFFFFTTTTTTTT
Add Comment
Please, Sign In to add comment