Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Sep 14 18:08
    @SethTisue banned @discjock:matrix.org
  • Sep 12 20:37
    @SethTisue banned @manuelzamoratetherbtcusa:matrix.org
  • Sep 06 14:29
    @SethTisue banned @white_hat_hacker:minds.com
  • Sep 06 14:29
    @SethTisue banned @alexchole:matrix.org
  • Aug 31 17:03
    @SethTisue banned @andersonwatts7:matrix.org
  • Jul 19 20:37
    @SethTisue banned @tonyobanon
  • Jan 02 23:58
    @SethTisue banned @fakubishes:nerdsin.space
  • Dec 15 2021 05:01
    som-snytt commented #12516
  • Dec 15 2021 04:38
    SethTisue edited #1312
  • Dec 15 2021 04:38
    SethTisue opened #2273
  • Dec 15 2021 04:31
    jackkoenig opened #12516
  • Dec 15 2021 04:29
    SethTisue edited #1312
  • Dec 15 2021 04:28
    SethTisue edited #1312
  • Dec 15 2021 04:27
    SethTisue labeled #9831
  • Dec 15 2021 04:27
    scala-jenkins milestoned #9831
  • Dec 15 2021 04:27
    SethTisue labeled #9831
  • Dec 15 2021 04:27
    SethTisue opened #9831
  • Dec 15 2021 03:35
    som-snytt commented #11339
  • Dec 15 2021 03:27
    som-snytt labeled #12494
  • Dec 15 2021 03:07
    SethTisue edited #1312
Ichoran
@Ichoran
Otherwise it would fail both lines.
Rob Norris
@tpolecat
Numeric types confuse the discussion I think because you have to think about weak conformance.
Ichoran
@Ichoran
Another case of the locality of type inference occurs with cases like def foo[A, B](a: A)(b: B, f: A => B) = ...
Ghost
@ghost~54f4b69115522ed4b3dcb16d
@mpasa with two X, you get a female option, but with a Y you get a male. There's a general sense that Y is more expendable; also, you can't rely on a Y when you need it. Sometimes a Y will transition to an X, and suddenly becomes pleasant to work with.
Ichoran
@Ichoran
Here, once you get past a: A, the compiler has decided what A is supposed to be. It can't use the stuff in f: A => B to help it decide.
Derek Wickern
@dwickern
so rust decides on the type of x the first time it's used?
Ichoran
@Ichoran
On the one hand that's bad, because you have to manually widen types. On the other hand, it's good because you can nail down your function types based on earlier arguments.
I think bad outweighs good, but it's not all purely bad :P
Klas Segeljakt
@segeljakt
yea it appears so
Ichoran
@Ichoran
Rust decides on the type of x the first time it is unambiguous what the type is.
It's not just when it's used. It can propagate "Hey, I don't know what type this is" for rather a while.
Harrison Houghton
@hrhino
@som-snytt what about in those rare and unfortunate cases where you get an XXY option?
OlegYch
@OlegYch
i'd guess it is necessary to support borrow checker and inference
Derek Wickern
@dwickern
it seems like that could get very confusing
do people abuse it?
Rob Norris
@tpolecat
Sounds like a kind of gruadual typing.
OlegYch
@OlegYch
linear
Rob Norris
@tpolecat
Well there's that too.
Klas Segeljakt
@segeljakt
what is linear typing?
Rob Norris
@tpolecat
I mean constraining a variable's type based on how it's used.
Miguel Pérez Pasalodos
@mpasa
@som-snytt thanks!
Ichoran
@Ichoran
For example, Rust is totally okay with this, and it's not because the 0 is naturally typed as u64:
fn main() {
    let a = 0;
    let mut b = a + a;
    let c = a + b;
    b += c;
    let d: u64 = c*b;
    println!("d is {}", d);   // Compile error
}
In contrast, with Scala, once you do val a = 0 it fixes the type as Int. If you want it to be something else, you have to say so there.
Klas Segeljakt
@segeljakt
I thought it had affine types
Ichoran
@Ichoran
Yeah, it has, actually, something a little bit more complicated than either affine or linear types.
But it's the same essence.
Klas Segeljakt
@segeljakt
ownership + move = affine?
but then you also have copy
and borrow
Ichoran
@Ichoran
It's affine-like, but there's the whole single-mutable-borrow-or-arbitrary-immutable-borrow thing.
Affine means "may use it at most once".
OlegYch
@OlegYch
borrow checking is pretty central to rust and i'd guess whatever flavor of substructural typing it has just naturally flows from that
Ichoran
@Ichoran
Linear, strictly speaking, means "must use it exactly once"
Klas Segeljakt
@segeljakt
I have tried to understand the “Region inference” for determining lifetimes
but I don’t get it
or, I get the general concept
Ichoran
@Ichoran
You really shouldn't, unless you're working on implementing the lifetime system. Just like you shouldn't try to understand explicitly all the steps the Scala compiler uses to do type inference.
Having a practical knowledge of how to get the languages to do what you want, or close enough, is fine.
Klas Segeljakt
@segeljakt
I am working on a master thesis for embedding Rust as a DSL in Scala
Ichoran
@Ichoran
In each case, the implementation details encompass enough tricky subcases that just hoping that....ah...you...what?!
Fabio Labella
@SystemFw
:)
Klas Segeljakt
@segeljakt
but I skipped the ownership system entirely
Ichoran
@Ichoran
Oh man. Well, you have your work cut out for you. For starters, the basic syntax is irreconcilably incompatible.
Klas Segeljakt
@segeljakt
xD
Ichoran
@Ichoran
So you'll need to write a compiler plugin to even get off the ground.
Klas Segeljakt
@segeljakt
I wrote a DSL for building an AST with GADT encoding
Fabio Labella
@SystemFw
or macros, no?
I think it really depends on what you mean by dsl
Ichoran
@Ichoran
Rust's if p { bar(); } else { foo(); } just won't work in Scala.
Fabio Labella
@SystemFw
rust"""
  rust code
"""
could be an option