GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Implement generics · Issue #154 · lcompilers/lpython

Implement generics #154

New issue
Copy link
New issue
Copy link
Open
Open
Implement generics#154
Copy link

Description

@certik
certik
opened on Feb 21, 2022
Issue body actions

We need to allow writing generic functions (templates) and template constraints.

One idea that we can explore is to also support something like: #152 (comment):

>>> def str(val: i32 | f64):
...   # "isinstance" type guard
...   if isinstance(val, i32):
...     # type of `val` is narrowed to `i32`
...     return str_int(val)
...   elif isinstance(val, f64):
...     # else, type of `val` is narrowed to `f64`
...     return str_float(val)

Activity

  1. Smit-create commented on Mar 13, 2022

    @Smit-create
    Smit-create
    on Mar 13, 2022
    Collaborator
    More actions

    This should now be possible with overload decorator.

  2. certik commented on Mar 13, 2022

    @certik
    certik
    on Mar 13, 2022
    ContributorAuthor
    More actions

    This particular case can be. We still need generics/templates.

    The overload in a sense is a subset of generics: you provide specific implementations ahead of time. The templates do not provide specific implementations, the compiler instantiates them.

  3. Aser-Abdelfatah commented on Sep 24, 2024

    @Aser-Abdelfatah
    Aser-Abdelfatah
    on Sep 24, 2024
    More actions

    Was this picked up by any person? Or is it still open for contribution?

  4. certik commented on Sep 25, 2024

    @certik
    certik
    on Sep 25, 2024
    ContributorAuthor
    More actions

    Yes, it's still open. We have quite solid generics in libasr thanks to LFortran, and we should hook them into LPython.

  5. Aser-Abdelfatah commented on Nov 7, 2024

    @Aser-Abdelfatah
    Aser-Abdelfatah
    on Nov 7, 2024
    More actions

    Hi,
    I'm doing more research into this. I found some generics implemented in GSoC 2022. I'd just appreciate if there were more details on which generics have higher priority or where to start

  6. certik commented on Nov 8, 2024

    @certik
    certik
    on Nov 8, 2024
    ContributorAuthor
    More actions

    They are implemented in LFortran, you can start here: https://docs.lfortran.org/en/asr/generics/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.