public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Per Bothner <per@bothner.com>
To: Duncan Mak <duncanmak@gmail.com>,
	kawa mailing list <kawa@sourceware.org>
Subject: Re: Disambiguate method from function
Date: Wed, 16 Dec 2020 02:59:01 -0800	[thread overview]
Message-ID: <2935bf5c-b1cb-59e9-7b88-98434db6f10e@bothner.com> (raw)
In-Reply-To: <CABgWrqrd5kVRtCjr6DAGFAAm2EPP0_fa3gVTvcTLY45ZuysrFA@mail.gmail.com>

On 12/16/20 12:49 AM, Duncan Mak via Kawa wrote:
> This doesn't work because I think it gets confused between hello the method
> and hello the function:
> 
> test.scm:3:4: call to 'hello' has too many arguments (1; must be 0)
> 
> 
> I could of course resolve this by renaming 'hello' the function to
> something like 'hello*', but is there another way to disambiguate the two?

Nothing I can think of to explicitly disambiguate.  (I tried some.)

I suggest using an alias:

(define-simple-class Person ()
   ((hello)
    (%hello "Calling from method")))

(define (hello message) (format #t "~A~%" message))
(define-alias %hello hello)

(hello "Calling from function")
((Person):hello)

-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

      reply	other threads:[~2020-12-16 10:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-16  8:49 Duncan Mak
2020-12-16 10:59 ` Per Bothner [this message]

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=2935bf5c-b1cb-59e9-7b88-98434db6f10e@bothner.com \
    --to=per@bothner.com \
    --cc=duncanmak@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).