home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / tcl / 2231 < prev    next >
Encoding:
Text File  |  1992-12-22  |  2.0 KB  |  50 lines

  1. Newsgroups: comp.lang.tcl
  2. Path: sparky!uunet!eco.twg.com!twg.com!news
  3. From: "David Herron" <david@twg.com>
  4. Subject: Re: Advice wanted on math functions for Tcl 7.0
  5. Message-ID: <1992Dec22.231908.7168@twg.com>
  6. Sensitivity: Personal
  7. Encoding:  30 TEXT , 4 TEXT 
  8. Sender: news@twg.com (USENET News System)
  9. Conversion: Prohibited
  10. Organization: The Wollongong Group, Inc., Palo Alto, CA
  11. Conversion-With-Loss: Prohibited
  12. Date: Tue, 22 Dec 1992 23:19:43 GMT
  13. Lines: 35
  14.  
  15. I've already voted for embedding trig functions in expr.  But I just
  16. had two thoughts which suggest third and fourth ways of doing this.
  17. One is by using array's and the other by introducing a new class
  18. of special things.
  19.  
  20. array
  21.  
  22. In this method the user writes: $sin(0.2).  A trap would be set up which
  23. interprets the index as floating point, computes the function, and returns it.
  24. Any programmer can write one of these arrays without having to extend expr.
  25. Also, expr's parsing doesn't have to be extended at all.  Instead it happens
  26. in Tcl_Eval().
  27.  
  28. Downside is you're back to converting back to strings which introduces
  29. needless and useless overhead.  Just because TCL is not a numerical programming
  30. language, it doesn't mean it has to PURPOSELY make numerical things slow.
  31.  
  32. function
  33.  
  34. In this case you'd introduce a new special leading character.  $'s introduce
  35. array/scalar references.  This new character (`%'?) would introduce a
  36. numerical function.  The user writes: %sin(0.2).  Some API function can
  37. be in the library which lets C programmers create these functions.  Some
  38. effort should be put into letting these stay in floating point if being
  39. interpreted by expr, and converted to strings if interpreted by Tcl_Eval().
  40. But my memory of the internals says this isn't likely.
  41.  
  42.  
  43. One definite need is a way for C programmers to extend the set of functions.
  44. Perhaps to include functions with multiple arguments?
  45.  
  46. <- David Herron <david@twg.com> (work) <david@davids.mmdf.com> (home)
  47. <-
  48. <- During the '80s Usenet's mantra was: "Not all the world's a VAX".
  49. <- During the '90s I hope it becomes:   "Not all the world's DOS (ick)".
  50.