Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use Declarations (type, inline, optimize) in Scheme?

How do I declare the types of the parameters in order to circumvent type checking?

How do I optimize the speed to tell the compiler to run the function as fast as possible like (optimize speed (safety 0))?

How do I make an inline function in Scheme?

How do I use an unboxed representation of a data object?

And finally are any of these important or necessary? Can I depend on my compiler to make these optimizations?

thanks, kunjaan.

like image 469
unj2 Avatar asked Jul 17 '26 23:07

unj2


1 Answers

  1. You can't do any of these in any portable way.
  2. You can get a "sort of" inlining using macros, but it's almost always to try to do that. People who write Scheme (or any other language) compilers are usually much better than you in deciding when it is best to inline a function.
  3. You can't make values unboxed; some Scheme compilers will do that as an optimization, but not in any way that is visible (because it is an optimization -- so it should preserve the semantics).
  4. As for your last question, an answer is very subjective. Some people cannot sleep at night without knowing exactly how many CPU cycles some function uses. Some people don't care and are fine with trusting the compiler to optimize things reasonably well. At least at the stages where you're more of a student of the language and less of an implementor, it is better to stick to the latter group.
like image 61
Eli Barzilay Avatar answered Jul 22 '26 14:07

Eli Barzilay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!