home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.arch:10872 comp.lang.misc:3761
- Path: sparky!uunet!kithrup!stanford.edu!agate!biosci!uwm.edu!zaphod.mps.ohio-state.edu!rpi!psinntp!psinntp!dg-rtp!sheol!throopw
- From: throopw@sheol.UUCP (Wayne Throop)
- Newsgroups: comp.arch,comp.lang.misc
- Subject: adding new operators on the fly
- Message-ID: <722061125@sheol.UUCP>
- Date: 18 Nov 92 01:44:01 GMT
- References: <1992Nov13.155126.3660@linus.mitre.org>
- Lines: 38
-
- : From: bs@gauss.mitre.org (Robert D. Silverman)
- : Message-ID: <1992Nov13.155126.3660@linus.mitre.org>
- : I would like to see a language that has a feature that will allow
- : me to (say) define new operators that use specific machine instructions.
- : for example: (pseudocode)
- :
- : define binary operator arg1 ** arg2 as 'emul arg1 arg2'
-
- This doesn't even begin to address all the necessary aspects of
- defining a new operator. What prescedence does "**" have? What are
- restrictions the compiler must know about which registers arg1 and arg2
- must be loaded into? What should the compiler do if there's a type
- mismatch in the arguments (eg: you try to do this to floating point
- numbers). And so on and on and on.
-
- These (among other reasons) are why gcc encourages access to assembly
- instructions with functional notation. You can at least specify input
- and output types, and you don't have to worry about operator
- prescedence issues, or lexical or syntactic ambiguity after the
- introduction of the new operator.
-
- There *are* languages that allow introduction of operators, but they
- sidestep a lot of the issues by not defining the operators in terms of
- machine instructions, but of other language constructs, and sidestep
- others by including notation for type compatibility and operator
- prescedence, and so on and on.
-
- Code generation just isn't as simple as associating a concrete instruction
- with an abstract operation, and syntactic recognition isn't as simple as
- spelling all the operators. The above notation doesn't even *begin*
- to be adequate to the task it is allegedly intended for.
-
-
- ( Now granted: the example was "pseudocode". But nevertheless, the
- example gives no clue how this pseudocode can even potentially be
- elaborated into a practical notation. )
- --
- Wayne Throop ...!mcnc!dg-rtp!sheol!throopw
-