Position Independent Source Code

Hex Artifact Content
Login

Artifact ce571f11ab168fb708235bc82e9a3cd76551e6f7:

Wiki page [Position Independent Source Code] by yumaikas 2018-09-02 14:50:04.
0000: 44 20 32 30 31 38 2d 30 39 2d 30 32 54 31 34 3a  D 2018-09-02T14:
0010: 35 30 3a 30 34 2e 37 36 33 0a 4c 20 50 6f 73 69  50:04.763.L Posi
0020: 74 69 6f 6e 5c 73 49 6e 64 65 70 65 6e 64 65 6e  tion\sIndependen
0030: 74 5c 73 53 6f 75 72 63 65 5c 73 43 6f 64 65 0a  t\sSource\sCode.
0040: 4e 20 74 65 78 74 2f 78 2d 6d 61 72 6b 64 6f 77  N text/x-markdow
0050: 6e 0a 50 20 34 65 37 35 30 38 35 33 62 35 30 66  n.P 4e750853b50f
0060: 33 35 31 36 38 33 38 39 30 37 64 38 37 34 31 63  3516838907d8741c
0070: 63 39 35 30 31 65 66 65 35 37 38 64 0a 55 20 79  c9501efe578d.U y
0080: 75 6d 61 69 6b 61 73 0a 57 20 32 39 33 35 0a 23  umaikas.W 2935.#
0090: 20 50 6f 73 69 74 69 6f 6e 20 49 6e 64 65 70 65   Position Indepe
00a0: 6e 64 65 6e 74 20 53 6f 75 72 63 65 20 43 6f 64  ndent Source Cod
00b0: 65 0d 0a 0d 0a 50 49 53 43 20 69 73 20 61 20 73  e....PISC is a s
00c0: 74 61 63 6b 2d 62 61 73 65 64 20 70 72 6f 67 72  tack-based progr
00d0: 61 6d 6d 69 6e 67 20 6c 61 6e 67 75 61 67 65 20  amming language 
00e0: 74 68 61 74 20 69 73 20 70 72 69 6d 61 72 69 6c  that is primaril
00f0: 79 20 69 6e 73 70 69 72 65 64 20 62 79 20 66 61  y inspired by fa
0100: 63 74 6f 72 2c 20 54 43 4c 2c 20 62 61 73 68 20  ctor, TCL, bash 
0110: 61 6e 64 20 61 20 6c 69 74 74 6c 65 20 62 69 74  and a little bit
0120: 20 6f 66 20 70 79 74 68 6f 6e 2c 20 77 72 69 74   of python, writ
0130: 74 65 6e 20 69 6e 20 67 6f 2e 20 49 74 27 73 20  ten in go. It's 
0140: 63 75 72 72 65 6e 74 6c 79 20 61 20 73 74 75 64  currently a stud
0150: 79 20 69 6e 20 68 6f 77 20 66 61 72 20 6f 6e 65  y in how far one
0160: 20 63 61 6e 20 74 61 6b 65 20 63 6f 64 65 20 71   can take code q
0170: 75 6f 74 61 74 69 6f 6e 73 2c 20 70 6f 6c 79 6d  uotations, polym
0180: 6f 72 70 68 69 63 20 73 74 61 63 6b 73 20 61 6e  orphic stacks an
0190: 64 20 70 65 72 76 61 73 69 76 65 20 64 79 6e 61  d pervasive dyna
01a0: 6d 69 73 6d 2e 0d 0a 0d 0a 43 75 72 72 65 6e 74  mism.....Current
01b0: 20 6c 6f 6e 67 65 72 20 74 65 72 6d 20 70 6c 61   longer term pla
01c0: 6e 20 5b 68 65 72 65 5d 28 68 74 74 70 73 3a 2f  n [here](https:/
01d0: 2f 70 69 73 63 2e 6a 75 6e 67 6c 65 63 6f 64 65  /pisc.junglecode
01e0: 72 2e 63 6f 6d 2f 68 6f 6d 65 2f 61 70 70 73 2f  r.com/home/apps/
01f0: 66 6f 73 73 69 6c 2f 50 49 53 43 2e 66 6f 73 73  fossil/PISC.foss
0200: 69 6c 2f 77 69 6b 69 3f 6e 61 6d 65 3d 4c 6f 6e  il/wiki?name=Lon
0210: 67 2d 54 65 72 6d 2b 50 6c 61 6e 73 29 0d 0a 0d  g-Term+Plans)...
0220: 0a 4e 6f 74 65 77 6f 72 74 68 79 20 74 68 69 6e  .Noteworthy thin
0230: 67 73 20 63 61 6e 20 62 65 20 66 6f 75 6e 64 20  gs can be found 
0240: 69 6e 20 74 68 65 20 5b 61 6e 6e 6f 75 6e 63 65  in the [announce
0250: 6d 65 6e 74 73 5d 5b 30 5d 20 0d 0a 0d 0a 3c 70  ments][0] ....<p
0260: 72 65 20 63 6c 61 73 73 3d 22 70 72 65 74 74 79  re class="pretty
0270: 70 72 69 6e 74 22 3e 0d 0a 22 48 65 6c 6c 6f 2c  print">.."Hello,
0280: 20 57 6f 72 6c 64 21 22 20 70 72 69 6e 74 6c 6e   World!" println
0290: 0d 0a 3c 2f 70 72 65 3e 0d 0a 0d 0a 54 6f 20 67  ..</pre>....To g
02a0: 65 74 20 61 20 66 65 65 6c 20 66 6f 72 20 74 68  et a feel for th
02b0: 65 20 62 61 73 69 63 73 20 6f 66 20 50 49 53 43  e basics of PISC
02c0: 2c 20 63 68 65 63 6b 20 6f 75 74 20 5b 50 49 53  , check out [PIS
02d0: 43 20 69 6e 20 59 20 6d 69 6e 75 74 65 73 5d 28  C in Y minutes](
02e0: 68 74 74 70 73 3a 2f 2f 70 69 73 63 2e 6a 75 6e  https://pisc.jun
02f0: 67 6c 65 63 6f 64 65 72 2e 63 6f 6d 2f 68 6f 6d  glecoder.com/hom
0300: 65 2f 61 70 70 73 2f 66 6f 73 73 69 6c 2f 50 49  e/apps/fossil/PI
0310: 53 43 2e 66 6f 73 73 69 6c 2f 77 69 6b 69 3f 6e  SC.fossil/wiki?n
0320: 61 6d 65 3d 50 49 53 43 2b 69 6e 2b 59 2b 4d 69  ame=PISC+in+Y+Mi
0330: 6e 75 74 65 73 29 0d 0a 0d 0a 53 6f 6d 65 20 65  nutes)....Some e
0340: 78 61 6d 70 6c 65 73 20 28 77 68 69 63 68 20 79  xamples (which y
0350: 6f 75 20 63 61 6e 20 74 72 79 20 69 6e 20 5b 74  ou can try in [t
0360: 68 65 20 70 6c 61 79 67 72 6f 75 6e 64 5d 5b 70  he playground][p
0370: 6c 61 79 5d 29 3a 20 0d 0a 0d 0a 3c 70 72 65 20  lay]): ....<pre 
0380: 63 6c 61 73 73 3d 22 70 72 65 74 74 79 70 72 69  class="prettypri
0390: 6e 74 22 3e 0d 0a 23 20 53 74 72 69 6e 67 20 62  nt">..# String b
03a0: 75 69 6c 64 69 6e 67 0d 0a 24 7b 20 0d 0a 20 20  uilding..${ ..  
03b0: 20 22 54 68 65 20 61 6e 73 77 65 72 20 69 73 20   "The answer is 
03c0: 22 20 0d 0a 20 20 20 36 20 37 20 2a 20 3e 73 74  " ..   6 7 * >st
03d0: 72 69 6e 67 20 0d 0a 20 20 20 22 2c 20 62 75 74  ring ..   ", but
03e0: 20 77 65 20 64 6f 6e 27 74 20 6b 6e 6f 77 20 74   we don't know t
03f0: 68 65 20 71 75 65 73 74 69 6f 6e 22 20 0d 0a 7d  he question" ..}
0400: 20 20 20 20 0d 0a 0d 0a 2f 2a 20 44 65 66 69 6e      ..../* Defin
0410: 69 6e 67 20 61 6e 20 61 64 6a 75 73 74 61 62 6c  ing an adjustabl
0420: 65 20 66 69 7a 7a 62 75 7a 7a 20 77 6f 72 64 20  e fizzbuzz word 
0430: 2a 2f 0d 0a 3a 20 66 69 7a 7a 62 75 7a 7a 2d 6e  */..: fizzbuzz-n
0440: 20 28 20 6e 20 2d 2d 20 29 20 3a 6e 20 2f 2a 20   ( n -- ) :n /* 
0450: 53 74 6f 72 65 20 66 72 6f 6d 20 73 74 61 63 6b  Store from stack
0460: 20 74 6f 20 6e 20 6c 6f 63 61 6c 20 2a 2f 0d 0a   to n local */..
0470: 20 20 20 20 31 20 3a 69 20 2f 2a 20 53 74 6f 72      1 :i /* Stor
0480: 65 20 31 20 69 6e 74 6f 20 6e 75 6d 20 76 61 72  e 1 into num var
0490: 69 61 62 6c 65 20 2a 2f 0d 0a 20 20 20 20 20 0d  iable */..     .
04a0: 0a 20 20 20 20 24 6e 20 5b 0d 0a 20 20 20 20 20  .    $n [..     
04b0: 20 20 20 24 69 20 33 20 64 69 76 69 73 6f 72 3f     $i 3 divisor?
04c0: 20 5b 20 22 46 69 7a 7a 22 20 5d 20 5b 20 22 22   [ "Fizz" ] [ ""
04d0: 20 5d 20 69 66 20 3a 66 0d 0a 20 20 20 20 20 20   ] if :f..      
04e0: 20 20 24 69 20 35 20 64 69 76 69 73 6f 72 3f 20    $i 5 divisor? 
04f0: 5b 20 22 42 75 7a 7a 22 20 5d 20 5b 20 22 22 20  [ "Buzz" ] [ "" 
0500: 5d 20 69 66 20 3a 62 0d 0a 20 20 20 20 20 20 20  ] if :b..       
0510: 20 24 66 20 24 62 20 73 74 72 2d 63 6f 6e 63 61   $f $b str-conca
0520: 74 20 3a 66 62 0d 0a 20 20 20 20 20 20 20 20 24  t :fb..        $
0530: 66 62 20 6c 65 6e 20 30 20 3e 20 5b 20 24 66 62  fb len 0 > [ $fb
0540: 20 70 72 69 6e 74 6c 6e 20 5d 20 5b 20 24 69 20   println ] [ $i 
0550: 70 72 69 6e 74 6c 6e 20 5d 20 69 66 20 0d 0a 20  println ] if .. 
0560: 20 20 20 20 20 20 20 2b 2b 69 0d 0a 20 20 20 20         ++i..    
0570: 5d 20 74 69 6d 65 73 20 3b 0d 0a 20 20 20 20 0d  ] times ;..    .
0580: 0a 32 35 20 66 69 7a 7a 62 75 7a 7a 2d 6e 0d 0a  .25 fizzbuzz-n..
0590: 3c 2f 70 72 65 3e 0d 0a 0d 0a 54 68 65 20 6c 61  </pre>....The la
05a0: 72 67 65 73 74 20 61 63 68 69 65 76 65 6d 65 6e  rgest achievemen
05b0: 74 20 69 6e 20 50 49 53 43 20 74 6f 20 64 61 74  t in PISC to dat
05c0: 65 20 69 73 20 61 20 5b 43 53 56 5d 28 2f 61 72  e is a [CSV](/ar
05d0: 74 69 66 61 63 74 2f 36 62 65 33 62 62 36 38 61  tifact/6be3bb68a
05e0: 66 37 65 33 37 38 34 29 20 70 61 72 73 65 72 2e  f7e3784) parser.
05f0: 0d 0a 0d 0a 23 20 49 6e 73 74 61 6c 6c 69 6e 67  ....# Installing
0600: 20 46 72 6f 6d 20 53 6f 75 72 63 65 0d 0a 0d 0a   From Source....
0610: 42 65 66 6f 72 65 20 79 6f 75 20 63 61 6e 20 69  Before you can i
0620: 6e 73 74 61 6c 6c 20 50 49 53 43 20 66 6f 72 20  nstall PISC for 
0630: 74 72 79 69 6e 67 20 6f 75 74 2c 20 79 6f 75 27  trying out, you'
0640: 6c 6c 20 6e 65 65 64 20 74 6f 20 69 6e 73 74 61  ll need to insta
0650: 6c 6c 20 5b 47 6f 20 31 2e 39 5d 5b 67 6f 31 39  ll [Go 1.9][go19
0660: 5d 20 6f 72 20 6e 65 77 65 72 2e 0d 0a 0d 0a 54  ] or newer.....T
0670: 68 65 72 65 20 61 72 65 20 74 77 6f 20 77 61 79  here are two way
0680: 73 20 74 6f 20 69 6e 73 74 61 6c 6c 20 50 49 53  s to install PIS
0690: 43 20 72 69 67 68 74 20 6e 6f 77 0d 0a 0d 0a 31  C right now....1
06a0: 29 20 49 6e 73 74 61 6c 6c 20 5b 66 6f 73 73 69  ) Install [fossi
06b0: 6c 5d 5b 66 6f 73 73 69 6c 5d 20 61 6e 64 20 72  l][fossil] and r
06c0: 75 6e 20 20 20 20 0d 0a 20 20 20 20 0d 0a 20 20  un    ..    ..  
06d0: 20 20 6d 6b 64 69 72 20 22 24 47 4f 50 41 54 48    mkdir "$GOPATH
06e0: 2f 73 72 63 2f 70 69 73 63 22 20 26 26 20 63 64  /src/pisc" && cd
06f0: 20 22 24 47 4f 50 41 54 48 2f 73 72 63 2f 70 69   "$GOPATH/src/pi
0700: 73 63 22 0d 0a 20 20 20 20 66 6f 73 73 69 6c 20  sc"..    fossil 
0710: 63 6c 6f 6e 65 20 68 74 74 70 73 3a 2f 2f 70 69  clone https://pi
0720: 73 63 2e 6a 75 6e 67 6c 65 63 6f 64 65 72 2e 63  sc.junglecoder.c
0730: 6f 6d 2f 68 6f 6d 65 2f 61 70 70 73 2f 66 6f 73  om/home/apps/fos
0740: 73 69 6c 2f 50 49 53 43 2e 66 6f 73 73 69 6c 20  sil/PISC.fossil 
0750: 50 49 53 43 2e 66 6f 73 73 69 6c 0d 0a 0d 0a 32  PISC.fossil....2
0760: 29 20 55 73 69 6e 67 20 67 69 74 3a 0d 0a 0d 0a  ) Using git:....
0770: 20 20 20 20 6d 6b 64 69 72 20 22 24 47 4f 50 41      mkdir "$GOPA
0780: 54 48 2f 73 72 63 2f 70 69 73 63 22 20 26 26 20  TH/src/pisc" && 
0790: 63 64 20 22 24 47 4f 50 41 54 48 2f 73 72 63 2f  cd "$GOPATH/src/
07a0: 70 69 73 63 22 20 0d 0a 20 20 20 20 67 69 74 20  pisc" ..    git 
07b0: 63 6c 6f 6e 65 20 67 69 74 68 75 62 2e 63 6f 6d  clone github.com
07c0: 2f 79 75 6d 61 69 6b 61 73 2f 50 49 53 43 2d 6d  /yumaikas/PISC-m
07d0: 69 72 72 6f 72 20 2e 0d 0a 0d 0a 49 6e 20 74 68  irror .....In th
07e0: 65 20 66 75 74 75 72 65 2c 20 61 20 64 69 66 66  e future, a diff
07f0: 65 72 65 6e 74 20 55 52 4c 20 66 6f 72 20 50 49  erent URL for PI
0800: 53 43 20 69 73 20 70 6c 61 6e 6e 65 64 2c 20 62  SC is planned, b
0810: 75 74 20 68 61 73 20 6e 6f 74 20 62 65 65 6e 20  ut has not been 
0820: 73 65 74 75 70 20 61 73 20 79 65 74 2e 0d 0a 0d  setup as yet....
0830: 0a 4f 6e 63 65 20 79 6f 75 20 68 61 76 65 20 47  .Once you have G
0840: 6f 2c 20 61 6e 64 20 68 61 76 65 20 50 49 53 43  o, and have PISC
0850: 20 73 6f 6d 65 77 68 65 72 65 20 77 68 65 72 65   somewhere where
0860: 20 74 68 65 20 67 6f 20 63 6f 6d 70 69 6c 65 72   the go compiler
0870: 20 63 61 6e 20 77 6f 72 6b 20 77 69 74 68 20 69   can work with i
0880: 74 2c 20 79 6f 75 20 63 61 6e 20 72 75 6e 20 60  t, you can run `
0890: 67 6f 20 67 65 74 60 20 74 6f 20 66 65 74 63 68  go get` to fetch
08a0: 20 50 49 53 43 27 73 20 67 6f 20 64 65 70 65 6e   PISC's go depen
08b0: 64 65 6e 63 69 65 73 2c 20 61 6e 64 20 60 67 6f  dencies, and `go
08c0: 20 62 75 69 6c 64 20 2d 6f 20 70 69 73 63 60 20   build -o pisc` 
08d0: 74 6f 20 62 75 69 6c 64 20 74 68 65 20 50 49 53  to build the PIS
08e0: 43 20 69 6e 74 65 72 70 72 65 74 65 72 2e 20 0d  C interpreter. .
08f0: 0a 0d 0a 4f 6e 63 65 20 79 6f 75 20 68 61 76 65  ...Once you have
0900: 20 50 49 53 43 20 62 75 69 6c 74 2c 20 60 70 69   PISC built, `pi
0910: 73 63 20 2d 69 60 20 77 69 6c 6c 20 6f 70 65 6e  sc -i` will open
0920: 20 61 6e 20 69 6e 74 65 72 61 63 74 69 76 65 20   an interactive 
0930: 50 49 53 43 20 73 65 73 73 69 6f 6e 2e 0d 0a 0d  PISC session....
0940: 0a 23 23 20 4f 74 68 65 72 20 69 74 65 6d 73 0d  .## Other items.
0950: 0a 5b 4c 69 73 74 20 6f 66 20 74 68 69 6e 67 73  .[List of things
0960: 20 74 6f 20 64 6f 5d 28 2f 77 69 6b 69 2f 74 6f   to do](/wiki/to
0970: 64 6f 29 2e 20 0d 0a 0d 0a 0d 0a 23 23 20 43 6f  do). ......## Co
0980: 6e 74 61 63 74 0d 0a 0d 0a 49 66 20 79 6f 75 20  ntact....If you 
0990: 68 61 76 65 20 71 75 65 73 74 69 6f 6e 73 20 61  have questions a
09a0: 62 6f 75 74 20 50 49 53 43 2c 20 66 65 65 6c 20  bout PISC, feel 
09b0: 66 72 65 65 20 74 6f 20 65 6d 61 69 6c 20 6d 65  free to email me
09c0: 20 61 74 20 79 75 6d 61 69 6b 61 73 39 34 20 61   at yumaikas94 a
09d0: 74 20 47 6f 6f 67 6c 65 27 73 20 6d 61 69 6c 20  t Google's mail 
09e0: 73 65 72 76 69 63 65 2e 20 0d 0a 0d 0a 0d 0a 5b  service. ......[
09f0: 30 5d 3a 20 68 74 74 70 73 3a 2f 2f 70 69 73 63  0]: https://pisc
0a00: 2e 6a 75 6e 67 6c 65 63 6f 64 65 72 2e 63 6f 6d  .junglecoder.com
0a10: 2f 68 6f 6d 65 2f 61 70 70 73 2f 66 6f 73 73 69  /home/apps/fossi
0a20: 6c 2f 50 49 53 43 2e 66 6f 73 73 69 6c 2f 74 69  l/PISC.fossil/ti
0a30: 6d 65 6c 69 6e 65 3f 6e 3d 35 30 26 79 3d 65 26  meline?n=50&y=e&
0a40: 76 3d 30 0d 0a 0d 0a 5b 7a 69 70 5d 3a 20 68 74  v=0....[zip]: ht
0a50: 74 70 73 3a 2f 2f 70 69 73 63 2e 6a 75 6e 67 6c  tps://pisc.jungl
0a60: 65 63 6f 64 65 72 2e 63 6f 6d 2f 68 6f 6d 65 2f  ecoder.com/home/
0a70: 61 70 70 73 2f 66 6f 73 73 69 6c 2f 50 49 53 43  apps/fossil/PISC
0a80: 2e 66 6f 73 73 69 6c 2f 7a 69 70 2f 50 6f 73 69  .fossil/zip/Posi
0a90: 74 69 6f 6e 2b 49 6e 64 65 70 65 6e 64 65 6e 74  tion+Independent
0aa0: 2b 53 6f 75 72 63 65 2b 43 6f 64 65 2d 66 36 30  +Source+Code-f60
0ab0: 36 30 66 66 65 33 32 2e 7a 69 70 3f 75 75 69 64  60ffe32.zip?uuid
0ac0: 3d 66 36 30 36 30 66 66 65 33 32 61 30 37 64 62  =f6060ffe32a07db
0ad0: 61 0d 0a 5b 74 61 72 5d 3a 20 68 74 74 70 73 3a  a..[tar]: https:
0ae0: 2f 2f 70 69 73 63 2e 6a 75 6e 67 6c 65 63 6f 64  //pisc.junglecod
0af0: 65 72 2e 63 6f 6d 2f 68 6f 6d 65 2f 61 70 70 73  er.com/home/apps
0b00: 2f 66 6f 73 73 69 6c 2f 50 49 53 43 2e 66 6f 73  /fossil/PISC.fos
0b10: 73 69 6c 2f 74 61 72 62 61 6c 6c 2f 50 6f 73 69  sil/tarball/Posi
0b20: 74 69 6f 6e 2b 49 6e 64 65 70 65 6e 64 65 6e 74  tion+Independent
0b30: 2b 53 6f 75 72 63 65 2b 43 6f 64 65 2d 66 36 30  +Source+Code-f60
0b40: 36 30 66 66 65 33 32 2e 74 61 72 2e 67 7a 3f 75  60ffe32.tar.gz?u
0b50: 75 69 64 3d 66 36 30 36 30 66 66 65 33 32 61 30  uid=f6060ffe32a0
0b60: 37 64 62 61 31 63 31 30 39 33 34 39 37 37 36 61  7dba1c109349776a
0b70: 30 62 65 66 33 31 37 31 31 65 64 30 20 0d 0a 5b  0bef31711ed0 ..[
0b80: 67 6f 31 39 5d 3a 20 68 74 74 70 73 3a 2f 2f 67  go19]: https://g
0b90: 6f 6c 61 6e 67 2e 6f 72 67 2f 64 6c 2f 0d 0a 5b  olang.org/dl/..[
0ba0: 66 6f 73 73 69 6c 5d 3a 20 68 74 74 70 3a 2f 2f  fossil]: http://
0bb0: 66 6f 73 73 69 6c 2d 73 63 6d 2e 6f 72 67 2f 78  fossil-scm.org/x
0bc0: 66 65 72 2f 75 76 2f 64 6f 77 6e 6c 6f 61 64 2e  fer/uv/download.
0bd0: 68 74 6d 6c 0d 0a 5b 70 6c 61 79 5d 3a 20 68 74  html..[play]: ht
0be0: 74 70 73 3a 2f 2f 70 69 73 63 2e 6a 75 6e 67 6c  tps://pisc.jungl
0bf0: 65 63 6f 64 65 72 2e 63 6f 6d 2f 70 6c 61 79 67  ecoder.com/playg
0c00: 72 6f 75 6e 64 2f 0a 5a 20 32 36 32 62 31 64 66  round/.Z 262b1df
0c10: 65 34 33 36 65 66 39 30 30 30 63 39 39 63 64 65  e436ef9000c99cde
0c20: 37 37 39 63 61 30 64 30 36 0a                    779ca0d06.