Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Constrained type parameters

$
0
0

When defining a type, is it possible to place a constraint on parameter values? For example, consider the following simple type definition:

struct Orf
   start::Int32
   stop::Int32
   pol::Int8
end

Is there any way to add a hint such as "stop > start" to this definition? In pseudo-code, it might resemble

struct Orf
   start::Int32
   stop::Int32, start > start
   pol::Int8 
end

In this way, data errors could be caught without explicit tests in code.

3 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles