On 2015-03-10 21:15:31+0100, Pascal J. Bourguignon wrote:
On 10 Mar 2015, at 17:02, Edi Weitz edi@weitz.de wrote:
After rummaging around in the HyperSpec and various implementation manuals I came to the following conclusion:
- The standard doesn't prescribe such thing as a default safety level
for CL implementations and there's no portable way to figure out the safety level of the global environment. (And the same holds for other optimize qualities.) The closest I could find in the CLHS is 3.3.1 where they talk about an "implementation that always processes code as if safety were high." From this I conclude that implementations are allowed NOT to do this or otherwise there would be no need to mention it.
The LispWorks manual for example describes the defaults in section 9.5 about compiler control, but for SBCL I couldn't find them in the manual.
- The standard doesn't prescribe what should happen if you try to
write an element of a wrong type to a specialized array, even in safe code.
Both LispWorks and SBCL will by default complain in this case but my understanding is that you can't rely on this in portable code.
So, my question is whether the above is correct or if I missed something?
Yes.
Notably, with (safety 0), Common Lisp implementation could be as good as common C implementations...
This is why it is very bad to put optimization declarations in libraries (well, if they're not (safety 3) (speed 0)): it HAS and WILL make users lose days in debugging because YOUR, Edi, libraries, compiled on conforming implementations fail to detect errors.
Hello!
This begs the question: how do I get a speed optimized library then? Do I need to make a local fork just to insert declarations? Is there a way to tell e. g. ASDF to use certain declamations? Is making the declarations in the library dependent on documented entries to *features* the way to go? Where would I push the desired settings into *features*?
Yours aye
Svante