Author Topic: Well tested common functions library - should we have it?  (Read 16329 times)

0 Members and 1 Guest are viewing this topic.

ymg

  • Guest
Re: Well tested common functions library - should we have it?
« Reply #30 on: December 09, 2013, 02:51:37 PM »
divtiply,

I suggest you test your so called "correct implementation" of ceil and floor function.

Graph provided by omegatron at http://commons.wikimedia.org/wiki/File:Floor_function.svg
Ceiling Function:


Floor Function:
« Last Edit: December 09, 2013, 02:56:58 PM by ymg »

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Well tested common functions library - should we have it?
« Reply #31 on: December 10, 2013, 02:26:43 AM »
Had a similar idea a while back: http://www.theswamp.org/index.php?topic=39158.5

And yes CL, because it's the only one where the namings of functions (and their argument orders and expected results) is already well established in the hyperspec. If you go with something like Scheme, then you have an extremely small subset which is a prerequisite of functions R6RS - all the rest is up for grabs by the user (never mind the implementer). That means if you choose Scheme as a base (or some of the others like NewLisp) then you'd have to go through the entire process of choosing names, arguments, expected results, etc .... could be a very lengthy process especially as it would need consensus. Why not take one which has already gone through such process for several decades (i.e. Common Lisp)?

If you choose something like CL, then at least that portion is already sorted out. You can then focus on the actual implementations instead of arguing about the naming. Just my opinion  :wink:

Edit: As per this discussion about floor/ceiling - http://www.lispworks.com/documentation/HyperSpec/Body/f_floorc.htm#floor
« Last Edit: December 10, 2013, 02:30:01 AM by irneb »
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

divtiply

  • Guest
Re: Well tested common functions library - should we have it?
« Reply #32 on: December 10, 2013, 10:23:40 AM »
divtiply,
I suggest you test your so called "correct implementation" of ceil and floor function.

Oops. My optimizing went too far. Initial (and correct) versions was:
Code: [Select]
(defun floor (num / n)
  (if (zerop (- num (setq n (fix num))))
    n
    (if (minusp num) (1- n) n)))
(defun ceiling (num / n)
  (if (zerop (- num (setq n (fix num))))
    num
    (if (minusp num) n (1+ n))))
But your new code is faster.
« Last Edit: December 17, 2016, 10:15:34 AM by divtiply »

LE3

  • Guest
Re: Well tested common functions library - should we have it?
« Reply #33 on: December 10, 2013, 10:57:16 AM »
For what I see so far, it will take you guys a lot of time just to agree in these two common functions... I know it is not my business to make you change (and not my intention et-al).... But see how easy can be to use the Math function for example in lisp - No rocket science:

Code - C#: [Select]
  1.         [LispFunction("Ceiling")]
  2.         public object Swamp_Ceiling(ResultBuffer resultBuffer)
  3.         {
  4.             if (resultBuffer == null || resultBuffer.AsArray().Any(tv => tv.TypeCode != RTREAL)) return null;
  5.             var number = (double)resultBuffer.AsArray().FirstOrDefault(tv => tv.TypeCode == RTREAL).Value;
  6.             return Math.Ceiling(number);
  7.         }
  8.  
  9.         [LispFunction("Floor")]
  10.         public object Swamp_Floor(ResultBuffer resultBuffer)
  11.         {
  12.             if (resultBuffer == null || resultBuffer.AsArray().Any(tv => tv.TypeCode != RTREAL)) return null;
  13.             var number = (double)resultBuffer.AsArray().FirstOrDefault(tv => tv.TypeCode == RTREAL).Value;
  14.             return Math.Floor(number);
  15.         }
  16.  


Even if those are done in C++/ARX:
Code - C++: [Select]
  1.         static int ads_ceil(void)
  2.         {
  3.                 struct resbuf *rb = acedGetArgs();
  4.                 if (!rb) return RSERR;
  5.                 if (rb && rb->restype != RTREAL) { acutPrintf(_T("\nError: function requires a RTREAL as argument. \n")); return RSERR; }
  6.                 acedRetReal(ceil(rb->resval.rreal));
  7.                 return (RSRSLT);
  8.         }
  9.  
  10.         static int ads_floor(void)
  11.         {
  12.                 struct resbuf *rb = acedGetArgs();
  13.                 if (!rb) return RSERR;
  14.                 if (rb && rb->restype != RTREAL) { acutPrintf(_T("\nError: function requires a RTREAL as argument. \n")); return RSERR; }
  15.                 acedRetReal(floor(rb->resval.rreal));
  16.                 return (RSRSLT);
  17.         }
  18.  

Well I leave you guys here..... want to stay in the lisp world - good --- and yes autolisp it is GREAT --- but have his limitations.

See ya! and have fun.

ymg

  • Guest
Re: Well tested common functions library - should we have it?
« Reply #34 on: December 10, 2013, 12:47:55 PM »
Quote
Well I leave you guys here..... want to stay in the lisp world - good --- and yes autolisp it is GREAT --- but have his limitations.

Luis,

I agree that Autolisp has his limitations. (Just like me  :-))

As far as moving to the .net world, probably getting too old for that.

ARX and all these carry a lot of overhead for the kind of programming we do.
I won't even compile to a VLX.

Sorry if the thread has taken this tone, but Yes! I was peeved.

ymg

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Well tested common functions library - should we have it?
« Reply #35 on: December 10, 2013, 11:47:31 PM »
Well I leave you guys here..... want to stay in the lisp world - good --- and yes autolisp it is GREAT --- but have his limitations.
I'm not sure how you want us to take this. But your samples aren't showing how C#/C++ is "better" than AutoLisp. It's just showing that there are already libraries you can use built into it. It wasn't always the case, the Math lib was an addon to C++, prior to that C/C++ programmers had to roll their own Ceil/floor functions too (it was actually one of the exercises I had to do in my programming degree - implement some standard math functions as a library in C++).

This entire thread is actually about implementing those libs so us AutoLispers have the use of them as well (instead of needing to design our own).
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Well tested common functions library - should we have it?
« Reply #36 on: December 11, 2013, 05:04:26 AM »
To quote from a different topic:

I look forward to seeing the implementation and documentation.
Yes, me too  :lol: ... that is the main thing isn't it?

@ irneb and divtiply:
What would it take to get this off the ground?

LE3

  • Guest
Re: Well tested common functions library - should we have it?
« Reply #37 on: December 11, 2013, 01:20:24 PM »
This entire thread is actually about implementing those libs so us AutoLispers have the use of them as well (instead of needing to design our own).

My point is to take advantage of what it is available - I come from a background in lisp too.

I just did an startup visual studio solution on my lunch break to export some of the Math library methods as autolisp functions, will open a new topic on the show your stuff and post the link later today here...

Have fun.

Edit: Here it is the link for my test project:
http://www.theswamp.org/index.php?topic=45841.msg509847#msg509847
« Last Edit: December 11, 2013, 02:14:58 PM by LE »

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Well tested common functions library - should we have it?
« Reply #38 on: December 12, 2013, 12:14:44 AM »
@ irneb and divtiply:
What would it take to get this off the ground?
Many things  :o most notably:
  • Someone (or rather more than one, or preferably some form of "organization") to take ownership of this.
  • A forum to propose new functions / items for inclusion to this library. Also to discuss & vote on these functions. Note if CL is used as a benchmark, much of this is already done for us - it's been tweaked since the '80s, so chances are that quite a lot of thought has already been incorporated
  • Some method of listing the accepted functions for inclusion, perhaps just a wiki page which could be the start of documentation
  • Another forum where implementations are proposed, discussed, "better" alternatives suggested and voted on.
  • A site where the latest version can easily be downloaded. This should also include a wiki-like documentation which can be downloaded to a local off-line file. Another reason CL is a good choice: much of the documentation is already in the hyperspec
  • A "would be nice to have" is also some buy-in from the manufacturers of the programs where AutoLisp features as an extension language. i.e. AutoCAD, BricsCAD and other similar clones. But, this is not a necessity, as most of the lib can be implemented as normal Lisp defuns instead of needing built-in additions. Further, most of these also provide other ways to add Lisp functions, like ARX/BRX, or even just through DotNet.

The list is probably not complete, but I think it shows the main hurdles to navigate.

If you guys feel creating a new project just for this is over the top, then feel free to join my Caddons project. I've already added some library functions there, together with some tools for use. It's just that I don't have the time to constantly give it the attention needed for such an undertaking on my own. It has a wiki built-in, as well as a forum for proposing "feature requests", bug reports and a general discussion.

Alternative (or in addition to) I've also started a wiki for listing possible extensions to AutoLisp, though its main aim is to revamp the entire Lisp engine to turn it into a much more powerful Lisping environment (perhaps a bit in excess of what this thread is about): http://alisp-ext.wikidot.com/

...I come from a background in lisp too...
Actually I came from the other side: Basic, Pascal, Java & C++ first, AutoLisp became like a drug after that, then I started looking at all the other Lisps and literally (note TRUE use of the word) fell in love with it. Thanks I'll take a look at that thread also.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Jeff H

  • Needs a day job
  • Posts: 6144
Re: Well tested common functions library - should we have it?
« Reply #39 on: December 12, 2013, 01:37:32 AM »
... < >
I wish I knew where to GIT that.  :wink: :wink:


stuffed up by kerry:
I wish I'd said that  :wink:
Oooops, I really stuffed that up .. sorry Jeff

« Last Edit: December 12, 2013, 02:50:27 AM by Kerry »

LE3

  • Guest
Re: Well tested common functions library - should we have it?
« Reply #40 on: December 12, 2013, 09:19:27 AM »
Actually I came from the other side: Basic, Pascal, Java & C++ first, AutoLisp became like a drug after that, then I started looking at all the other Lisps and literally (note TRUE use of the word) fell in love with it. Thanks I'll take a look at that thread also.

Wow --- That's interesting - Hope and guess you still use at least the C++ and have that advantage. I am glad that I am out of lisp as I used to.... still can do some minor stuff when needed.
Have fun!

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Well tested common functions library - should we have it?
« Reply #41 on: December 13, 2013, 12:49:35 AM »
Wow --- That's interesting - Hope and guess you still use at least the C++ and have that advantage. I am glad that I am out of lisp as I used to.... still can do some minor stuff when needed.
Have fun!
Actually I despised C++, I try to avoid it as much as possible - did then (mid '90s) and still feel the same. I actually preferred Java and Pascal, so C# came nearly naturally to me (it's so close to Java as to make next to no difference). None of them (however) gives me the same sense of accomplishment through absolute minimum input that Lisp does. But that's just me.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: Well tested common functions library - should we have it?
« Reply #42 on: December 13, 2013, 03:32:26 AM »
Actually I despised C++, I try to avoid it as much as possible - did then (mid '90s) and still feel the same. I actually preferred Java and Pascal, so C# came nearly naturally to me (it's so close to Java as to make next to no difference). None of them (however) gives me the same sense of accomplishment through absolute minimum input that Lisp does. But that's just me.
I think it is a very widespread opinion, this is also one of the reasons for the success of Bricscad and their effort to make it compatible the maximum possible with VisualLisp. This is also demonstrated by the number of topics:
Code: [Select]
Posts            TheSwamp
-------------------------
AutoLISP (Visual)   76919
VB(A)                8467
.NET                24517
ARX Programming      2745
General Programming  7244

Topics           TheSwamp  Autodesk
-----------------------------------
AutoLISP (Visual)    6831      1842
VB(A)                 910       801
.NET                 2774       271
ARX Programming       335       304
General Programming   783
It seems that the topics of Autodesk begin by 1999, but many have been lost, especially of AutoLISP.

LE3

  • Guest
Re: Well tested common functions library - should we have it?
« Reply #43 on: December 13, 2013, 09:30:35 AM »
OK, the link for some other option to use, it is there now, it have also some more information provided by Gile too. LE!

ymg

  • Guest
Re: Well tested common functions library - should we have it?
« Reply #44 on: December 13, 2013, 12:55:02 PM »
Quote
Actually I despised C++, I try to avoid it as much as possible - did then (mid '90s) and still feel the same.

You can count me in in the group that love to hate C++.

Now, If we could get optional argument to function and array (Not the monster we got now).....!

ymg