oops. i didn't meant to turn it into private conversation.. there are some bits which can be useful/interesting to others :) ---------- Forwarded message ---------- From: Igor Stasenko <siguctua@gmail.com> Date: 10 May 2012 23:07 Subject: Re: [Pharo-project] Native Boost and Slang To: lenglish5@cox.net On 10 May 2012 22:07, Lawson English <lenglish5@cox.net> wrote:
On 5/10/12 12:00 PM, Igor Stasenko wrote:
woot .. 68 videos.. you are really productive! :)
Thanks.
BTW, I was wondering if there would be an easy way to return the formatted string from a printf() call.
printing: Â NBCPrinter printf: 'aString'
returns nil
because printf() function returns void. (nothing) which replaced by NB by nil (since unlike from C, every method has to answer something) for returning formatted string you can use snprintf() function.   int   snprintf(char * restrict str, size_t size, const char * restrict format, ...); here in first argument you should pass a ByteArray instance, or ByteString, big enough to accomodate formatted string, size is maximum number of characters for that buffer (pass the size of bytearray/string) the rest is like in printf. But NB does not supports variable arguments.
Also, I'm looking at providing bindings to a few of the functions in gmplib  http://gmplib.org/
and the examples http://web.mit.edu/gnu/doc/html/gmp_4.html show that I should always call mpz_clear (&result) unless I am "exiting the program". I assume this means I should always call mpz_clear (&result) but of course, if I do that, I don't have a valid return value.
you clear it , when you no longer need it. in terms of smalltalk, you must finalize the object which represents external resource to call mpz_clear there. See WeakRegistry & friends. You can also use NBExternalResourceManager, which i added recently. See its comment for instructions how to use it.
Can I embed several external calls within a single {} or should I make each gmp call a "private" method and wrap the calls in a public method or...?
It is easy to write a code in NB which makes multiple calls to different functions inside same primitive. But of course you will need to make your hands dirty with some assembly. The high level interface allows you to make callouts only to a single function.
Thanks
Lawson
-- Best regards, Igor Stasenko. -- Best regards, Igor Stasenko.