public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Panicz Maciej Godek <godek.maciek@gmail.com>
To: kawa@sourceware.org
Subject: Type information seems to be erased in macros
Date: Wed, 29 Dec 2021 23:12:37 +0100	[thread overview]
Message-ID: <CAMFYt2YrXxPx84adKFH+ig=ZJN2rSKUaEhmLrAMS6R+NM3MmGQ@mail.gmail.com> (raw)

Hi,
I have defined a macro:

(define-syntax-rule (with-translation screen (x y) . actions)
  (let ((x! x)
        (y! y))
    (screen:translate! x! y!)
    (let ((result (begin . actions)))
      (screen:translate! (- x!) (- y!))
      result)))

which (presumably) operates on Screen interface, which provides translate!
method.

I use it in a context which makes it clear that the type of the first
argument passed to with-translation is Screen:

(define (draw! object #!optional (screen::Screen (current-screen)))::Extent
  ...
  (with-translation screen (left top) ...)
  ...)

However, when I import (to the REPL) a module containing this code, I get
the following complaint near the use of the with-translation macro:

warning - no known slot 'translate!' in java.lang.Object

Does the macro system erase type information from objects?

If I add explicit casts in the macro, is it likely to cause some
performance penalty?

             reply	other threads:[~2021-12-29 22:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-29 22:12 Panicz Maciej Godek [this message]
2021-12-29 23:30 ` Per Bothner
2021-12-30  8:52   ` Panicz Maciej Godek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMFYt2YrXxPx84adKFH+ig=ZJN2rSKUaEhmLrAMS6R+NM3MmGQ@mail.gmail.com' \
    --to=godek.maciek@gmail.com \
    --cc=kawa@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).