public inbox for
 help / color / mirror / Atom feed
From: Per Bothner <>
To: Peter Lane <>,
Subject: Re: building int[] arrays at runtime
Date: Wed, 01 Feb 2017 23:41:00 -0000	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On 02/01/2017 03:12 PM, Peter Lane wrote:
> If I build an int[] at runtime, I get a warning about more than one applicable method.  The code seems to run and give the right result, so the runtime does the right thing.  As the warning always appears first, when the script is loaded, I assume the script is compiled on loading and so the problem is discovered.
> I understand why I'm getting this warning, but wondered if:
> a. I should do something other than (apply int[] (list 3)) to create an int[] at runtime

Yes, use the '@' splice operator:

(*x*:show (int[] @(list 3)))

This doesn't seem to be documented in the release manual, but it is documented
in the documentation for the "invoke" development branch:

(But note a bunch of this stuff doesn't work in the release or the master branch.
However, the splice operator '@' does work.)

> b. Can I put a compile-time type hint in, to appease/suppress the initial checks?

Use the 'as' special function:

(*x*:show (as int[] (apply int[] (list 3))))

That's basically a type cast.
	--Per Bothner

  reply	other threads:[~2017-02-01 23:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-01 23:12 Peter Lane
2017-02-01 23:41 ` Per Bothner [this message]
2017-02-02 18:43   ` Peter Lane
2017-02-01 23:45 ` Per Bothner

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:

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

  git send-email \ \ \ \ \

* 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).