Simple MAPCAR must be replaced by a slightly more complicated DO, because the
list may not be a proper list. I want to dedicate this ballad to myself.
This is a tale of a sorry quest
To master pure code at the T guru's behest
I enrolled in a class that appealing did seem
For it promised to teach fine things like T3 and Scheme
The first day went fine; we learned of cells
And symbols and lists and functions as well
Lisp I had mastered and excited was I
For to master T3 my hackstincts did cry
I sailed through the first week with no problems at all
And I even said "closure" instead of "function call"
Then said the master that ready were we
To start real hacking instead of simple theory
Will you, said he, write me a function please
That in lists would associate values with keys
I went home and turned on my trusty Apollo
And wrote a function whose definition follows:
(cdr (assq key a-list))
A one-liner I thought, fool that I was
Just two simple calls without a COND clause
But when I tried this function to run
CDR didn't think that NIL was much fun
So I tried again like the good King of yore
And of code I easily generated some more:
(cond ((assq key a-list) => cdr))
It got longer but purer, and it wasn't too bad
But then COND ran out and that was quite sad
Well, that isn't hard to fix, I was told
Just write some more code, my son, be bold
Being young, not even a moment did I pause
I stifled my instincts and added a clause
(cond ((assq key a-list) => cdr)
(else nil))
Sometimes this worked and sometimes it broke
I debugged and prayed and even had a stroke
Many a guru tried valiantly to help
But undefined datums their efforts did squelch.
I returneth once more to the great sage of T
For no way out of the dilemma I could see
He said it was easy -- more lines must I fill
with code, for FALSE was no longer NIL.
(let ((val (assq key a-list)))
(cond (val (cdr val))
(else nil)))
You'd think by now I might be nearing the end
Of my ballad which seems bad things to portend
You'd think that we could all go home scot-free
But COND eschewed VAL; it wanted #T
So I went back to the master and appealed once again
I said, pardon me, but now I'm really insane
He said, no you're not really going out of your head
Instead of just VAL, you must use NOT NULL instead
(let ((val (assq key a-list)))
(cond ((not (null? val)) (cdr val))
(else nil)))
My song is over and I'm going home to bed
With this ineffable feeling that I've been misled
And just in case my point you have missed
Somehow I preferred (CDR (ASSQ KEY A-LIST))
-- Ashwin Ram,
"A Short Ballad Dedicated to Program Growth"
Professor Giuseppe Attardi was kind enough to elaborate on the history of
ECL. I've rewritten the history chapter to include more precise dates and
elaborate on other implementations. Also updated inheritance graphs to
indicate, that ECL is a descendant of DELPHI Common Lisp and that there is no
cross-pollination between ECoLisp and AKCL.
We can't use the standard functions like cl_list for allocating the
wrapper object for the finalizer since these need a working environment
for disabling interrupts.
We also need the interrupt_struct in the fake env to allow explicitely
checking for interrupts on platforms where this doesn't happen implicitely
by using mprotect.
Always use the byte sized input/output operations ReadConsoleA/WriteConsoleA
and do all the conversion to unicode by ourself.
Moreover, expand the set of known encodings for Windows codepages and print
a warning if we encounter an unsupported codepage.
Fixes#582.
We need to compile the function body in the same environment in which
the function was defined. However the function arguments need to be
compiled in the current argument.
Fixes#577.
Unify handling of LAMBDA and LAMBDA-BLOCK in c1funcall and c1apply,
split off computation of let bindings and body in
optimize-funcall/apply-lambda into a separate function.
Preliminary work to fix inlining of local closures.
This is more consistent with other streams for which file-position
doesn't make sense, which also just return nil instead of signaling
errors.
Fixes#580.
We can't use ecl_process_env_unsafe() == NULL to check if ECL has
booted because the return value of ecl_process_env_unsafe is
unpredictable before ECL has booted. The reason is that
ecl_process_env_unsafe calls pthread_getspecific with an uninitialized
key stored in cl_env_key. But another call to pthread_setspecific
might have already registered a key which happens to be the same as
the not yet initialized cl_env_key, yielding a non-NULL value.
Only call handlers established in the current thread and use atomic
operations to update *descriptor-handlers*.
Closes#588.
Additionally:
- improve the test code
- add a test for the leak
- provide internet machine link for the tutorial
That makes lambda with a declaration si:function-block-name behave
consistently with ext:lambda-block (and in eval-macros
ext:lambda-block expands to have this declaration too to behave in
turn consistently with how the compiler treats ext:lambda-block).
Recursive locks may be determined from the object header while reading
the counter is wrong, because at a time of testing with the CV counter
may be exactly 1 despite the fact that the lock is recursive.
If getrlimit fails, new_size may be zero. Furthermore, getrlimit may also return
RLIM_INFINITY in which case new_size is way to large. In both cases the real stack size is
unknown and we can only use some sensible default.