Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5983893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:17:46+00:00 2026-05-22T22:17:46+00:00

In common-lisp, I want to implement a kind of reference system like this: Suppose

  • 0

In common-lisp, I want to implement a kind of reference system like this:

Suppose that I have:

(defclass reference () ((host) (port) (file)))

and also I have:

(defun fetch-remote-value (reference) ...) which fetches and deserializes a lisp object.

How could I intervene in the evaluation process so as whenever a reference object is being evaluated, the remote value gets fetched and re-evaluated again to produce the final result?

EDIT:

A more elaborate description of what I want to accomplish:

Using cl-store I serialize lisp objects and send them to a remote file(or db or anything) to be saved. Upon successful storage I keep the host,port and file in a reference object. I would like, whenever eval gets called on a reference object, to first retrieve the object, and then call eval on the retrieved value. Since a reference can be also serialized in other (parent) objects or aggregate types, I can get free recursive remote reference resolution by modyfing eval so i dont have to traverse and resolve the loaded object’s child references myself.

EDIT:
Since objects always evaluate to themselves, my question is a bit wrongly posed. Essentially what I would like to do is:

I would like intercept the evaluation of symbols so that when their value is an object of type REFERENCE then instead of returning the object as the result of the symbol evaluation, to return the result of (fetch-remote-value object) ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:17:47+00:00Added an answer on May 22, 2026 at 10:17 pm

    In short: you cannot do this, except by rewriting the function eval and modifying your Lisp’s compiler. The rules of evaluation are fixed Lisp standard.

    Edit After reading the augmented question, I don’t think, that you can achieve full transperency for your references here. In a scenario like

    (defclass foo () (reference :accessor ref))
    (ref some-foo)
    

    The result of the call to ref is simply a value; it will not be considered for evaluation regardless of its type.

    Of course, you could define your accessors in a way, which does the resolution transparently:

    (defmacro defresolver (name class slot)
        `(defmethod ,name ((inst ,class))
            (fetch-remote-reference (slot-value inst ',slot))))
    
    (defresolver foo-reference foo reference)
    

    Edit You can (sort of) hook into the symbol resolution mechanism of Common Lisp using symbol macros:

    (defmacro let-with-resolution (bindings &body body) 
        `(symbol-macrolet ,(mapcar #'(lambda (form) (list (car form) `(fetch-aux ,(cadr form)))) bindings) ,@body))
    
    (defmethod fetch-aux ((any t)) any)
    (defmethod fetch-aux ((any reference)) (fetch-remote-reference any))
    

    However, now things become pretty arcane; and the variables are no longer variables, but magic symbols, which merely look like variables. For example, modifying the content of a variable “bound” by this macro is not possible. The best you can do with this approach is to provide a setf expansion for fetch-aux, which modifies the original place.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with common lisp. I want to pass a string to
I want to implement my particle filtering algorithm in parallel in Common Lisp. Particle
I am currently have a small program in Common Lisp, which I want to
I have been writing Common Lisp macros, so Scheme's R5Rs macros are a bit
In Peter Seibel's Practical Common Lisp , he gives this example: (do ((nums nil)
I'm trying to implement some data structures (like HAMP-hash array mapped trie) in Common
If you want to make CLOS objects in common lisp printable (print readably), how
Why would anyone prefer Scheme macros over Common Lisp macros (and I genuinely want
Common Lisp HyperSpec says that require and ****modules**** are deprecated. But I still see
In common lisp I can do this: (mapcar #'cons '(1 2 3) '(a b

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.