home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / editors / 3036 < prev    next >
Encoding:
Text File  |  1992-12-14  |  2.8 KB  |  69 lines

  1. Newsgroups: comp.editors
  2. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!pacific.mps.ohio-state.edu!davis
  3. From: davis@pacific.mps.ohio-state.edu ("John E. Davis")
  4. Subject: Re: Extension Languages
  5. In-Reply-To: marks@iris.mincom.oz.au's message of 14 Dec 92 03:28:08 GMT
  6. Message-ID: <DAVIS.92Dec14120625@pacific.mps.ohio-state.edu>
  7. Sender: news@pacific.mps.ohio-state.edu
  8. Nntp-Posting-Host: pacific.mps.ohio-state.edu
  9. Reply-To: davis@pacific.mps.ohio-state.edu  (John E. Davis)
  10. Organization: "Dept. of Physics, The Ohio State University"
  11. References: <3859@iris.mincom.oz.au>
  12. Date: Mon, 14 Dec 1992 17:06:25 GMT
  13. Lines: 54
  14.  
  15. In article <3859@iris.mincom.oz.au> marks@iris.mincom.oz.au (Mark Stavar)
  16. writes: 
  17.    IS there any specific reason why one would choose to utilise an prefix
  18.    notation language for extensions to an editor as opposed to infix or
  19.    post-fix? 
  20.  
  21.  
  22. For my JED editor,  I invented a language which I call S-Lang or ``Ssslang''.
  23. It is stack based and resembles postscript in many ways.  However unlike other
  24. stack based languages, it supports local variables which tremendously simply
  25. taking care of the stack.  However, this is not just an editor language---
  26. rather it is a language embedded into the editor.  I am currently writing a
  27. program which utilizes a frame grabber and I have embedded the languge in it
  28. as well.  So for example, suppose I have a C function called `draw' which
  29. takes 4 integers and draws a line between two points and returns nothing.
  30. Then to embed this function in the language, simply put:
  31.  
  32. add_intrinsic("line", draw, VOID_TYPE, 4);
  33.  
  34. in your C program.  Then you can call the function from within Slang:
  35.  
  36. 1 1 10 10 line  ;; draws a line between points (1,1) and (10,10)
  37.  
  38. Then you can create a function called `box':
  39.  
  40. ( [x1 y1 x2 y2]        ;; local variables
  41.   =y2 =x2 =y1 =x1
  42.  
  43.   x1 y1 x1 y2 line
  44.   x1 y2 x2 y2 line
  45.   x2 y2 x2 y1 line
  46.   x2 y1 x1 y1 line
  47. ) box
  48.  
  49. Then  `1 2 10 12 box' will draw a box with two corners at (1,2) and (10,12).
  50. I think that you can see how such a program adds a new dimension to a program
  51. with a C function called draw.  In addition, think about how you would have to
  52. write the box function with NO local variables using stack operators `dup',
  53. `exch', `roll', etc....
  54.  
  55. The reason I chose a stack based language is easy:  The parsing stage is
  56. simple.  I did not want most of the executable devoted to the language.
  57.  
  58. I will release Slang as a standalone product soon.  Of course it is not really
  59. standalone because it needs to be embedded into you application.  Look at my
  60. JED sources (in ledit.c) to see how Slang is embedded.
  61. --
  62.      _____________
  63. #___/John E. Davis\_________________________________________________________
  64. #
  65. # internet: davis@amy.tch.harvard.edu
  66. #   bitnet: davis@ohstpy
  67. #   office: 617-735-6746
  68. #
  69.