#rust-lang

/

      • dcassian_ has quit
      • korczis_ joined the channel
      • oln has quit
      • cp joined the channel
      • Ixrec has quit
      • korczis_ has quit
      • korczis_ joined the channel
      • korczis_ has quit
      • AstralSorcerer joined the channel
      • Jesin joined the channel
      • jseyfried has quit
      • jseyfried joined the channel
      • scottmcm
        centril: finding a way to not have special const traits, to not have to make multiple versions of things that differ only in constness of arguments, etc sounds quite valuable
      • Diggsey has quit
      • dcassiano joined the channel
      • Muhannad joined the channel
      • dcassiano has quit
      • Muhannad has quit
      • Muhannad joined the channel
      • Muhannad has quit
      • Muhannad joined the channel
      • Muhannad has quit
      • warmwaffles has quit
      • zmt99 has quit
      • mermi joined the channel
      • dcassiano joined the channel
      • dcassiano has quit
      • mermi has left the channel
      • kimundi has quit
      • kimundi joined the channel
      • Muhannad joined the channel
      • Muhannad has quit
      • Muhannad joined the channel
      • Muhannad has quit
      • Muhannad joined the channel
      • Muhannad has quit
      • niconii has quit
      • Muhannad joined the channel
      • AstralSorcerer has quit
      • Muhannad has quit
      • Muhannad joined the channel
      • behnam joined the channel
      • Muhannad has quit
      • behnam has quit
      • behnam joined the channel
      • behnam has quit
      • oln joined the channel
      • behnam joined the channel
      • Muhannad joined the channel
      • Ixrec joined the channel
      • Muhannad has quit
      • Muhannad joined the channel
      • Muhannad has quit
      • Muhannad joined the channel
      • Muhannad has quit
      • Muhannad joined the channel
      • jseyfried has quit
      • Ixrec has quit
      • Muhannad has quit
      • Muhannad joined the channel
      • Muhannad has quit
      • arielby joined the channel
      • Muhannad joined the channel
      • Muhannad has quit
      • Muhannad joined the channel
      • Muhannad has quit
      • oln has quit
      • centril
        scottmcm: yeah - did you read the discussion I and eddyb had btw? it might suggest that const + MIRI is too powerful for it to be useful to have T: const Trait for a non-const fn
      • behnam has quit
      • dcassiano joined the channel
      • scottmcm
        I don't even really know what the rules for `const fn` are
      • I just never want to see both `fn foo` and `const fn foo_const` next to each other :P
      • centril
        scottmcm: as far as I understood it, const fn:s must be deterministic
      • that's it, basically
      • scottmcm: for a const-fn called at runtime, this means that for the exact same runtime values (as arguments), the const-fn must produce the same return value, or, "produce exactly the same sequence of actions"
      • well, these would be the limits of const-fn - but it's not the story today
      • dcassiano has quit
      • isHavvy
        Arguably you could have a non-const version that is more optimized.
      • centril
        isHavvy: depends on what you can do in a const context, in the future const may be powerful enough to write the optimized version
      • In any case, we can have `const impl`s (all fn:s must be const), or we can have const-fn:s in impl:s and then for it to be callable from a const context all fn:s in the impl must be const-fn:s
      • eddyb: Thinking about it again, `const impl` and `impl X for Y { const fn ... }` (const-fn on every item) is not much of a difference
      • eddyb: on the T: const Trait part, I think both syntaxes can be used - then we have: for a normal fn, you must write T: const Trait to require "all methods are const", and for a const-fn, T: Trait implicitly means T: const Trait
      • so I think we can have our cake and eat it too
      • korczis_ joined the channel
      • tho I think I prefer the syntax `const impl` cause a trait could actually want to write: trait Foo { const fn bar(I) -> R; }
      • korczis_ has quit
      • tho I think impl Foo for X { const fn bar(I) -> R; } has no conflict with "all fn:s must be const" , for some traits, the only impl:s will be "all fn:s are const" ones.
      • we can use `const impl` as sugar for putting `const` on all fn:s
      • before I run off to write that RFC, someone please break the proposal apart :P
      • cc nmatsakis, woboats ^
      • nagisa joined the channel
      • eddyb
        centril: it seems okay. the reason I didn't want T: const Trait if T: Trait already does something is to avoid confusion
      • with e.g. const N: usize
      • centril
        eddyb: ah - that is syntactically different tho: const N: Type vs. T: const Trait
      • I think it is sufficiently noticable
      • eddyb
        centril: not ambiguity, confusion
      • centril
        eddyb: yeah got that
      • eddyb
        it's just const moved horizontally, that's not enough IMO :P
      • centril
        im saying the risk of confusion is not that great
      • eddyb
        because honestly the syntax for const generics could've well been N: const usize
      • and we might actually want to use "const usize" somewhere as a syntax
      • centril
        eddyb: still you have the trait/type difference as well
      • eddyb
        you can agree that less syntax in the language is objectively better, right?
      • so far I'm not aware of a real usecase of T: const Trait on a non-const fn
      • centril
        eddyb: sure, less syntax is better
      • but more expressivity is also better =)
      • eddyb: so I think perhaps we can start of with T: const Trait in the RFC and if no one likes it we can relegate to "maybe in the future"
      • and have it as an unanswered question
      • eddyb
        yes but expressivity for what?
      • centril
        or perhaps the reverse - start w/o it and have it as an unanswered question
      • eddyb
        I prefer the latter :P
      • centril
        eddyb: so im sure there's a use case - i just cant think of it now
      • :D
      • eddyb
        centril: I've thought about it for years and I doubt it
      • centril
        eddyb: ah =)
      • eddyb: but it's good to know there are no technical difficulties at least
      • we have the option if we like to use it
      • anyways - time to go do some TA:ing
      • eddyb
        const fn's are not really meaningful at runtime because we can't fully enforce the compile-time/runtime distinction is not observed
      • a const fn could detect it's at runtime and use an escape hatch to employ non-determinisim
      • or the detection of runtime itself involves a source of non-determinisim, I suppose
      • so it would have to be a compile-time use within a non-const fn
      • centril: you're probably looking at this all wrong IMO
      • centril: if you want to make an argument for T: const Trait it should be about using it in a constant location that's not a const fn
      • array lengths, associated consts in an impl, triggering rvalue promotion
      • that sort of thing
      • cp has quit
      • dcassiano joined the channel
      • Aaronepower has quit
      • dcassiano has quit
      • dcassiano joined the channel
      • pnkfelix
        RalfJ: ping
      • Aaronepower joined the channel
      • arielby has quit
      • arielby joined the channel
      • ariel_ joined the channel
      • Muhannad joined the channel
      • Aaronepower has quit
      • dcassiano has quit
      • Aaronepower joined the channel
      • ariel_ has quit
      • rkruppe-phone joined the channel
      • cp joined the channel
      • arielby has quit
      • Aaronepower has quit
      • Muhannad has quit
      • rkruppe-phone_ joined the channel
      • rkruppe-phone has quit
      • dcassiano joined the channel
      • rkruppe-phone_ has quit