<dougmacdoug>
how does the new keyword work on primitives? Its used on the builtins like F32.epsilon() but I didnt see anything in the docs
<Praetonus>
dougmacdoug: Not sure what you mean by "how does it work". Do you have an example to illustrate your question?
<dougmacdoug>
new min_value() =>
<dougmacdoug>
"""
<dougmacdoug>
Minimum negative value representable.
<dougmacdoug>
"""
<dougmacdoug>
from_bits(0xFF7FFFFF)
<dougmacdoug>
from primitive F32
<dougmacdoug>
is it compiled into a constant? what type does the numeric value have what capabilities does it have
<SeanTAllen>
dougmacdoug: F32.min_value()
<dougmacdoug>
yeah, i know how to call it.. i am just trying to comprehend how it works and is there any use case for the new keyword on primitives outside compile_intrinsic
<Praetonus>
Numeric primitives are special-cased in the code generator. Their constructors are compiled as functions returning plain numeric values
<jemc>
dougmacdoug: the "machine word" / numeric primitives are kind of a special case for how they work
<dougmacdoug>
ok.. makes sense.. so then user defined primitives should always use fun ?
<Praetonus>
You can use a constructor on an user defined primitive if you want to run some code every time the primitive instance is accessed
<jemc>
all other `primitive`s in Pony are singleton, stateless, immutable value that represents a pointer to a bag of functions
<Praetonus>
e.g. if you have a primitive `Prim` with a `create` constructor, using `Prim` as an expression will be sugared to `Prim.create()`, which will execute the code in the constructor and return the singleton instance of `Prim`
khan has quit [Quit: khan]
<dougmacdoug>
ok.. yeah, I got most of that from the docs but browsing the builtin led me to wonder about new keyword. thanks.
<jemc>
what is the new keyword you're referring to?
<dougmacdoug>
"new"
<SeanTAllen>
krig: you around?
xllndr has quit [Quit: Leaving]
<SeanTAllen>
krig: i sent some pony-sform feedback, mostly in the way of questions.