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

augmenting README #27

Open
JeffreySarnoff opened this issue Nov 19, 2021 · 2 comments
Open

augmenting README #27

JeffreySarnoff opened this issue Nov 19, 2021 · 2 comments

Comments

@JeffreySarnoff
Copy link
Contributor

There are no separate docs yet. Considering what ought be mentioned, I am editing the README (to become a PR when clean and of our agreement).

Here is a start with some questions,

  • should Static.dynamic become part of the interface example?
  • should NDIndex be described as an external export, or is it for special uses?
  • how to describe StaticBool with True, True(), False, False()?
  • what is a good intro explaining why and where to use this?

Static

Stable
Dev
Build Status
Coverage

Static defines a limited set of statically parameterized types and a common interface that is shared between them. Defining a new static type that conforms with this interface only requires defining the following:

  • Static.static(::T) - given the non-static type T return its static counterpart.
  • Static.dynamic(::Type{S})- given the static type S return the known non-static type.
  • Static.is_static(::Type{S}) - given the static type S return True() (else False())
  • Static.known(::Type{S})- given the static type S return the known non-static value.

Fore example, the following would appropriately define the interface for StaticChar

Static.static(x::Char) = StaticChar(x)
Static.dynamic(::Type{StaticChar}) = Char
Static.is_static(::Type{T}) where {T<:StaticChar} = True()
Static.known(::Type{StaticChar{C}}) where {C} = C::Char

Exported Types

  • StaticBool, True, False
  • StaticInt, StaticFloat64
  • StaticSymbol
  • NDIndex
@dlfivefifty
Copy link

Can you actually explain what a static type is in the readme?

@Tokazama
Copy link
Collaborator

I like this so far.

Can you actually explain what a static type is in the readme?

It means known "statically" or at compile time. It's comparable to Val(x) but it functions like whatever x is. This is extremely useful for producing generic code for static and dynamic values (StaticInt and Int).

We should probably find a way of also communicating that this is predominantly for the purpose of overcoming problems with constant propagation. Unlike previous efforts in this area, we're not pushing to have a static counterpart to everything in Base. So the Char example may be a bit misleading because if there is a consistent need for text that is statically known, then we should probably build it into StaticSymbol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants