Check if the file system is case-insensitive

  Kiến thức lập trình

In Common Lisp, is it possible to programmatically manipulate a lexical environment at runtime?

If I create a closure, typical let-over-lambda, as described in D. Hoytes LOL-book, how can I augment the closure with a new binding, or remove a binding? Consider something simple as this:

(use-package :sb-cltl2)

(let ((foo "foo"))
  (defun print-foo ()
    (format t "Foo: ~a~%" foo)))

How do I add a new variable ‘(bar “bar”) to the lexical environment of this variable, and how do I add a new function ‘print-bar’ to it. Is that even possible?

As a follow-up: are lexical closures only live on the stack during the execution, or are they objects on the heap, live during the lifetime of the application?

I have been looking into CLTL2 environments, and and I am not really sure I understand how to use this stuff. Almost all functions and macros from that extension, require the environment to be passed in as an argument, but there does not seem to be a way to obtain an existing environment from the system? Perhaps I am wrong about it. The wording is “standardeese” so I might be misinterpreting something there too. I am not overly familiar with Common Lisp either.

The only thing that seems remotely usable, is the define-declaration, which will generate a function (a handler as they call it), with strict requirement for it’s lambda list and return value. Now, I am not sure how to use that thing. For the first, what is “named declaration” in this case? The one I specify as the parameter to this macro as decl-name? I am confused what are decl-name and ‘lambda-list’ in “define-declaration decl-name lambda-list {form}*”. Lambda list for the handler or my print-foo function? I tried various things, but I failed, so I turned to SX gurus as the last option. As I understand, this handler is actually is meant to be called by augment-environment? Or they mean they have used this to implement augment-environment? I still see this with obtaining environment as very opaque, and don’t understand how to connect the actual alist (environment) they speak about to my handler.

I have been looking at SBCL source code, in implementation of function-information and variable-information and I could steal their code to get this info, but that is of course non-portable and erroneous approach.

ELI5-me please, I understand I am a n00b, just spare me idiot declarations and arrogance if possible. I admit publicly I am not familiar with this, and am completely confused how this works in practice. I really have trouble to understand what they talk about there.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT