public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Kumar Appaiah <a.kumar@alumni.iitm.ac.in>
To: kawa@sourceware.org
Subject: Re: Query on using `stream-cons' with srfi-14
Date: Thu, 24 Jul 2014 03:43:00 -0000	[thread overview]
Message-ID: <20140724034341.GB14862@odessa> (raw)
In-Reply-To: <53CFF493.9000706@bothner.com>

On Wed, Jul 23, 2014 at 10:44:51AM -0700, Per Bothner wrote:
> 
> 
> On 07/23/2014 04:23 AM, Kumar Appaiah wrote:
> >Hi.
> >
> >I'm trying out the SICP examples on streams using kawa. I am currently
> >stuck on a stream example. The particular blurb of code is:
> >
> >(define cons-stream stream-cons)
> >(define the-empty-stream stream-null)
> > ...
> >Running this gives me the following error:
> >Argument  '#<macro stream-cons>' to 'apply-to-args' has wrong type (kawa.lang.Macro) (expected: procedure)
> >         at gnu.kawa.functions.ApplyToArgs.applyN(ApplyToArgs.java:165)
> 
> >What am I doing wrong? Please let me know if I am not being clear.
> 
> stream-cons is syntax - specifically a macro.
> It doesn't work to treat it as a value that is
> available at run-time.  (It might be reasonable for Kawa
> to warn about this.)
> 
> You would need to define cons-stream as a macro, for
> example (untested code):
> 
> (define-syntax cons-stream
>   (syntax-rules ()
>     ((_ a b) (stream-cons a b))))

Indeed, this works well. I was not acquainted with define-syntax and
friends, so thank you for the explanation.

Kumar
-- 
Kumar Appaiah

      parent reply	other threads:[~2014-07-24  3:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-23 11:23 Kumar Appaiah
2014-07-23 17:45 ` Per Bothner
2014-07-23 18:01   ` Jamison Hope
2014-07-24  3:42     ` Kumar Appaiah
2014-07-24  3:43   ` Kumar Appaiah [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=20140724034341.GB14862@odessa \
    --to=a.kumar@alumni.iitm.ac.in \
    --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).