Dechenjm / crack-language

Automatically exported from code.google.com/p/crack-language
Other
0 stars 0 forks source link

Bignums in crack (an attempt) #131

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I have been playing around with a rudimentary GMP wrapper in crack.

https://github.com/wbhart/crack-bignum/blob/master/bignum.crk

(Actually it's currently using MPIR not GMP, but the obvious change to the 
first line of actual code will change that -- I am the maintainer of MPIR).

Is this of interest?

I realise:

* There are many bugs
* The code doesn't currently conform to crack coding guidelines
* It isn't module-ified

However, comments on how to make the code more idiomatic are appreciated.

Original issue reported on code.google.com by goodwill...@googlemail.com on 29 Dec 2014 at 11:48

GoogleCodeExporter commented 9 years ago
Yes, this is very much of interest.  The code is generally not too far from 
crack's internal style guide.  Some comments:

- Use 4 character soft tabs, not 3.
- Use extensions for wrapping C code instead of direct shared library imports 
(these are convenient for local hacks but sacrifice portability).
- Use "##", "///" or "/** */" style comments for documenting classes and 
methods, eventually documentation tools will extract these.
- Break out tests into test scripts (or screen test drivers, see the "crkt" 
files) and break out examples into example modules.

We've actually talked about the possibility of introducing bignum constants.  
If we did, we'd want to add this to crack.lang (directly or as an import).

Original comment by mind...@gmail.com on 30 Dec 2014 at 11:13

GoogleCodeExporter commented 9 years ago
I have now extended the bignum functionality quite a bit. There's still quite a 
few additional things that would be required to round it out.

The most annoying is randomisation. There are incompatibilities between GMP and 
MPIR for that functionality (for good reasons). It's probably best to implement 
randomisation directly in crack rather than use GMP for that.

Everything that is currently implemented in bignum.crk should work ok with both 
GMP and MPIR.

Unfortunately I have not found time to attend to your suggestions. Obviously 
the most pressing need is a test suite and to fix all the bugs it shows up.

I will very slowly begin adding such over the coming weeks. Unfortunately my 
Christmas->New Year break is over, so I can't keep working on this at the same 
pace now.

I'll update when this is cleaned up a bit.

Original comment by goodwill...@googlemail.com on 1 Jan 2015 at 1:36