Le vendredi 30 octobre 2015 à 20:43 -0700, Eric Forgy a écrit :
> Thank you Jacob.
>
> I've now got my Enums working following your suggestion (embarrassed
> for asking), but now I am unclear whether there is any benefit to
> using enums versus just creating a bunch of instances of a composite
> i
Thank you Jacob.
I've now got my Enums working following your suggestion (embarrassed for
asking), but now I am unclear whether there is any benefit to using enums
versus just creating a bunch of instances of a composite immutable type.
Any wisdom you can share on the circumstances under which
Eric,
Currently in Julia, officially supported Enums can only take on integer
values. This excludes the ability to use an arbitrary type as values for
enum members. You could, however, use enums as a part of a solution:
@enum Country Brazil China Canada USA etc.
immutable CountryData
field1:
Hi Mauro,
Thank you for your response and sorry I did not ask very clearly. Let me try
again.
I am considering creating a composite immutable type. I know there will always
only be a finite number of them, e.g. Country, and I'd like to just create them
in the beginning of my code. Each Country
I don't quite understand what you fail to achieve. Using other values
than integers for the enum does not work, if that is the question.
If you just try to make your custom enum, then it cannot be used with
the @enum macro.
immutable MyEnum
field1::Type1
filed2::Type2
end
# no need/use
I am thinking about making an Enum type MyEnum, but each MyEnum is a
composite immutable type. Is that possible (recommended) and how could I do
that?
I've looked at
- https://github.com/JuliaLang/julia/pull/10168
- And the @enum section of Docs
but it still isn't obvious to me yet how t
Ok now that you have put it there, the comments in the documentation make
more sense to me. It looks like both yours and mine are essentially
equivalent, but yours is simpler. I was aiming for the following behavior
with my implementation:
- different enum types won't typecheck (can't do "if e1
We definitely need a standard solution to this in Base Julia. We may have
enough example use cases at this point to know what it needs to look like.
Relevant issue: https://github.com/JuliaLang/julia/issues/3080
On Mon, Jan 26, 2015 at 3:11 PM, Mauro wrote:
> There is a FAQ entry on this which
There is a FAQ entry on this which suggests not to use types each of
elements of the enum (if I recall correctly).
I recently did a enum like this:
export nonstiff, mildlystiff, stiff
abstract Enum
immutable Stiff <: Enum
val::Int
function Stiff(i::Integer)
@assert 0<=i<=2
Hey all. I have frequently been in the position of wanting enumerations in
Julia. I have finally settled on the implementation linked below which lets
me refer to flags
in a named way and only specify their underlying numbering once. Is this
the best way, or are there better ways I haven't figur
10 matches
Mail list logo