🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.editors
Article #2509

Re: Extension Languages

#2509
From: "John E. Davis"
Date: Mon, 14 Dec 1992 17:06
54 lines
2909 bytes
In article <3859@iris.mincom.oz.au> marks@iris.mincom.oz.au (Mark Stavar)
writes: 
   IS there any specific reason why one would choose to utilise an prefix
   notation language for extensions to an editor as opposed to infix or
   post-fix? 


For my JED editor,  I invented a language which I call S-Lang or ``Ssslang''.
It is stack based and resembles postscript in many ways.  However unlike other
stack based languages, it supports local variables which tremendously simply
taking care of the stack.  However, this is not just an editor language---
rather it is a language embedded into the editor.  I am currently writing a
program which utilizes a frame grabber and I have embedded the languge in it
as well.  So for example, suppose I have a C function called `draw' which
takes 4 integers and draws a line between two points and returns nothing.
Then to embed this function in the language, simply put:

add_intrinsic("line", draw, VOID_TYPE, 4);

in your C program.  Then you can call the function from within Slang:

1 1 10 10 line  ;; draws a line between points (1,1) and (10,10)

Then you can create a function called `box':

( [x1 y1 x2 y2]        ;; local variables
  =y2 =x2 =y1 =x1

  x1 y1 x1 y2 line
  x1 y2 x2 y2 line
  x2 y2 x2 y1 line
  x2 y1 x1 y1 line
) box

Then  `1 2 10 12 box' will draw a box with two corners at (1,2) and (10,12).
I think that you can see how such a program adds a new dimension to a program
with a C function called draw.  In addition, think about how you would have to
write the box function with NO local variables using stack operators `dup',
`exch', `roll', etc....

The reason I chose a stack based language is easy:  The parsing stage is
simple.  I did not want most of the executable devoted to the language.

I will release Slang as a standalone product soon.  Of course it is not really
standalone because it needs to be embedded into you application.  Look at my
JED sources (in ledit.c) to see how Slang is embedded.
--
     _____________
#___/John E. Davis\_________________________________________________________
#
# internet: davis@amy.tch.harvard.edu
#   bitnet: davis@ohstpy
#   office: 617-735-6746
#
Technical Details
Message-ID: <DAVIS.92Dec14120625@pacific.mps.ohio-state.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!pacific.mps.ohio-state.edu!davis
References: <3859@iris.mincom.oz.au>

Show Full Headers
Complete Article Headers
Newsgroups: comp.editors
Path: arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!pacific.mps.ohio-state.edu!davis
From: davis@pacific.mps.ohio-state.edu ("John E. Davis")
Subject: Re: Extension Languages
In-Reply-To: marks@iris.mincom.oz.au's message of 14 Dec 92 03:28:08 GMT
Message-ID: <DAVIS.92Dec14120625@pacific.mps.ohio-state.edu>
Sender: news@pacific.mps.ohio-state.edu
Nntp-Posting-Host: pacific.mps.ohio-state.edu
Reply-To: davis@pacific.mps.ohio-state.edu  (John E. Davis)
Organization: "Dept. of Physics, The Ohio State University"
References: <3859@iris.mincom.oz.au>
Date: Mon, 14 Dec 1992 17:06:25 GMT
Lines: 54