<nyarum>
Guys, who can give details about "trn" rcap? Because this rcap haven't use in std and we can know about this only from tutorial. And after I don't know where I can use that rcap :3
<nyarum>
hasn't used*
SilverKey has quit [Quit: Halted.]
<jemc>
nyarum: most common use of a `trn` is when you want to create a mutable reference (as `trn`), do some operations to build it up, then convert it to an immutable reference (`val`)
<jemc>
because `trn` is write-unique (it's th only reference that can mutate the object), you can drop your `trn` (`consume` it) to guarantee that no writable references exist anymore, and thus get a `val`
<jemc>
we don't have a rope in the standard library yet, but we've been thinking about adding one
<jemc>
but the benefit of a rope is the ability to concatenate strings to eachother without copying/reallocating them - the rope just accumulates a tree of chunks and provides string-like access to that list
<nyarum>
jemc: thanks :)
SilverKey has quit [Quit: Halted.]
Matthias247 has joined #ponylang
nyarum has quit [Quit: Leaving.]
gsteed has quit [Quit: Leaving]
SilverKey has joined #ponylang
Matthias247 has quit [Read error: Connection reset by peer]
aturley has quit [Ping timeout: 252 seconds]
polypus74 has joined #ponylang
<polypus74>
is there a way of getting a polymorphic numeric literal?
<polypus74>
my goal is to have a float on the left hand side call an add function other than the standard lib one
<polypus74>
let x: MyType = 3 + MyType
<jemc>
polypus74: no, as of now, Pony does not let you bind a different add function than what currently exists for a type
<jemc>
however, your example wouldn't work anyway, because Pony needs a way to know what type of literal that `3` is
<jemc>
so you'd have to say something like `let x: MyType = U64(3) + MyType`
<jemc>
and at that point, you're not saving on verbosity compared to something like `let x: MyType = MyType(3) + MyType`
<jemc>
I would note that just changing the order here solves both problems - this would work fine: `let x: MyType = MyType + 3`
<jemc>
(assuming you define an appropriate add function for `MyType`, like `fun add(that: U64): MyType => ...`
<polypus74>
ok ty. yeah order works for add but i want to support non-commutative ops (-,/) etc
<jemc>
yeah, your best bet is to use `MyType(3)`, since you need a hint to tell the type of the literal anyway, as in `U64(3)`
<polypus74>
too bad i have to use wrapper, just a little bit more verbose, but not the end of the world. why "as of now"? are there plans for the future which might change things
<jemc>
no, as far as I know it's not on any roadmap
<jemc>
probably a bad choice of words, but I basically meant to imply that such a thing would not be impossible to support, but we don't support it
<jemc>
polypus74: not sure what your use case is for this line of questioning, but if you're just trying to declare a type that acts like a certain numeric type, but the type system sees as distinct and unrelated, this might be a relevant ticket to follow: https://github.com/ponylang/ponyc/issues/317
<polypus74>
i guess compiler is not smart enough to guess that it is the only applicable type in the case of a union type. type MyType is (MyBaseType | F64). i've been messing around with this idea without much luck. will have a look at ticket. use case is basically a DSL that compiles down to a DSP signal flow graph
<jemc>
"DSL that compiles down to a DSP signal flow graph" >> ah, very cool - sounds similar to a project that's been rattling around in my head for a while but haven't made much progress on due to other priorities - I'd definitely be interested to see what you come up with
<polypus74>
right now i'm basically a complete noob so could be a good while but will do :)
<jemc>
polypus74: regarding your first sentence - not sure what you ran into but the following does compile fine for me: `let x: (MyBaseType | F64) = 3`