Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better implicit array typing #117

Closed
ventor3000 opened this issue May 24, 2012 · 2 comments
Closed

Better implicit array typing #117

ventor3000 opened this issue May 24, 2012 · 2 comments
Labels

Comments

@ventor3000
Copy link
Contributor

Feature request.

The following code, which implicitly tells Nimrod that vars test and test2 are TAnimalArray:s does not work. Implicit casting of the elements in array to TAnimal should be done.

type
TAnimal=object
PAnimal=ref TObject

TDog=object of TAnimal
PDog=ref TDog

TCat=object of TAnimal
PCat=ref TCat

TAnimalArray=array[0..2,PAnimal]

proc newDog():PDog = new(result)

proc newCat():PCat = new(result)

proc test(a:openarray[PAnimal])=
echo("dummy")

test(newDog(),newCat()) #does not work

var myarray:TAnimalArray=[newDog(),newCat(),newDog()] #does not work

var myarray2:TAnimalArray=[newDog(),newDog(),newDog()] #does not work either

@AdrianV
Copy link
Contributor

AdrianV commented Jul 14, 2012

+1
It is annoying to cast back to PAnimal every time

@reactormonk
Copy link
Contributor

Nicely formatted:

type
  TAnimal=object {.inheritable.}
  PAnimal=ref TObject

  TDog=object of TAnimal
  PDog=ref TDog

  TCat=object of TAnimal
  PCat=ref TCat

  TAnimalArray=array[0..2,PAnimal]

proc newDog():PDog = new(result)
proc newCat():PCat = new(result)
proc test(a:openarray[PAnimal])=
  echo("dummy")

test(newDog(),newCat()) #does not work
var myarray:TAnimalArray=[newDog(),newCat(),newDog()] #does not work
var myarray2:TAnimalArray=[newDog(),newDog(),newDog()] #does not work either

Yep, implement covariance :-P

Araq added a commit that referenced this issue May 4, 2013
@zah zah closed this as completed May 5, 2013
reactormonk pushed a commit to reactormonk/nim that referenced this issue Apr 7, 2014
Clyybber added a commit to Clyybber/Nim that referenced this issue Oct 16, 2020
Clyybber added a commit that referenced this issue Nov 15, 2020
narimiran pushed a commit that referenced this issue Nov 16, 2020
(cherry picked from commit 92da06e)
PMunch pushed a commit to PMunch/Nim that referenced this issue Jan 6, 2021
mildred pushed a commit to mildred/Nim that referenced this issue Jan 11, 2021
irdassis pushed a commit to irdassis/Nim that referenced this issue Mar 16, 2021
ardek66 pushed a commit to ardek66/Nim that referenced this issue Mar 26, 2021
krux02 pushed a commit to krux02/Nim that referenced this issue Jan 11, 2022
This pull enables `koch.py` to build a bootstrap compiler from bundled
csources in release archives.

This allow a build from the source archive to be network-less.

Included is a small fix to ensure that `koch.py` is packaged in release
archives.

This pull also changes the source archive layout a fair bit, with all of
`csources` being placed in `/build/csources` instead of `/`.
krux02 pushed a commit to krux02/Nim that referenced this issue Jan 11, 2022
117: koch.py: support csources in release archives r=alaviss a=alaviss

This pull enables `koch.py` to build a bootstrap compiler from bundled csources in release archives.

This allow a build from the source archive to be network-less.

Included is a small fix to ensure that `koch.py` is packaged in release archives.

This pull also changes the source archive layout a fair bit, with all of `csources` being placed in `/build/csources` instead of `/`.

Co-authored-by: Leorize <leorize+oss@disroot.org>
krux02 pushed a commit to krux02/Nim that referenced this issue Jan 11, 2022
118: rework release archive creation r=saem a=alaviss

This is a big change, but most of it circles around the model of archive
creation embedded in niminst.

Previously niminst have two modes of operations: either it creates a
binary zip archive for Windows, or it creates a source tar.xz archive
for Unix.

This commit refactored that into three new pieces:

- `archive`: The main command to create a release archive. By default
             this archive contains only source code, and the source
             archive can be used to create binary archives.
- `--format`: A switch allowing selection of the release archive format.
- `--binaries`: A switch that set archive build mode to "binary
                archive", where either windows or unix (or both)
                binaries will be included in the archive. In this mode,
                files not relevant to the target platforms will also be
                omitted.

With these, koch is now equipped with some "new" commands:

- `archive`: Create a source archive
- `winrelease`: Create a binary zip archive for Windows
- `unixrelease`: Create a binary tarball for Unix-like

Some are removed:

- `testinstall`: Automated test to see if Unix binaries can be built
                 from sources. Currently have too many assumptions on
                 the way the old architecture work, so it is axed for
                 now.
- `zip`: superseded by `winrelease`
- `xz`: superseded by `archive`

And finally, `installer.ini` is updated to synchronize the binary list
with what is actually built.

Depends on nim-lang#117

Co-authored-by: Leorize <leorize+oss@disroot.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants