#rust

/

      • zygentoma joined the channel
      • somewone_ has quit
      • rainemak joined the channel
      • sevvie
        eval: (-0.0, 0.0)
      • NOTICE: (-0.0, 0.0)
      • cgfbee joined the channel
      • richinseattle joined the channel
      • jschievink joined the channel
      • arunkumar413
        I'm finding the symbols :: & -> hard to remember. Are there any aliases for these
      • zygentoma has quit
      • scottmcm
        vorner: it's absolutely a good thing to do; I was just surprised :)
      • arunkumar413
        Why can't we just use functions or methods for these shmbols
      • scottmcm
        arunkumar413: well, `::` and `->` are straight syntax; it'd be impossible to use functions or methods for htem
      • raingloom joined the channel
      • vorner
        arunkumar413, The :: and & are from C++.
      • arunkumar413
        What is & for
      • vorner
        The -> is from mathematics and it means it maps input into output
      • OmniMancer
        references
      • vorner
        taking address/reference.
      • OmniMancer
        the -> is also kinda from C++
      • vorner
        Well, haskell used -> much longer than C++.
      • OmniMancer
        s/taking address/borrowing/
      • arunkumar413
        May can't we just create a function to get the address or memory
      • A.men()
      • Instead of symbol
      • vorner
        Because you do it too often and what would be signature of that method?
      • arunkumar413
        a.memory():
      • scottmcm
        arunkumar413: why do we use a `.` to end a sentence instead of writing "full stop" like a telegraph?
      • arunkumar413
        It's a convention we folloe
      • netrino joined the channel
      • fsasm joined the channel
      • scottmcm: not a good comparison
      • OmniMancer
        producing a reference is a somewhat fundamental operation that cannot be implemented with the semantics of a function or method (with the exception of auto borrowing but that is a convenience feature)
      • Havvy
        Just practice using the symbols long enough and you'll get them memorized.
      • OmniMancer
        also you'd still need some way to write a reference type
      • jesusbv has quit
      • jesusbv_ has quit
      • stratact
        Anyone here use clap-rs? I how do I specify the value name for a subcommand?
      • jesusbv_ joined the channel
      • jesusbv joined the channel
      • scottmcm
        well, the type could just be `Ref<T>` like `Box<T>` is special
      • arunkumar413
        OmniMancer: so i can build a function that fetches the address
      • Havvy
        stratact: SubCommand::with_name("get") ?
      • OmniMancer
        arunkumar413: no you cannot
      • stratact
        Havvy: doesn't that specify the subcommand name, instead of the value name?
      • OmniMancer
        you can write a method that gives you a reference to the thing you call it on with some caveats, but it doesn't actually make the reference and just exploits the convenience of not having to borrow something to call a method that takes a reference
      • arunkumar413
        For example
      • Havvy
        Maybe. What do you mean by value name?
      • arunkumar413
        B=&A
      • scottmcm
        arunkumar413: anyway, this is the kind of thing that isn't realistically going to change, so there's not much point in discussing it
      • arunkumar413
        Will be hold the address of A
      • ?
      • OmniMancer
        B will be a reference to A which was borrowed from A
      • mib_h82tfw joined the channel
      • starblue1 has quit
      • mib_h82tfw has quit
      • zippity joined the channel
      • arunkumar413
        So both a and b hold same value?
      • OmniMancer
        no
      • Havvy
        "Sorta"
      • zippity
        why alloc::alloc does not return Nonnull?
      • stratact
        Havvy: As in: `foo bar <VALUE>`, where foo is the command and bar is the subcommand, and <VALUE> is the required value name
      • vorner
        A holds a value. B only knows where A lives so you can go find A and look into it instead.
      • Havvy
        .arg(Arg::with_name("KEY").index(1)
      • stratact
        ah, interesting
      • Havvy
        On the SubCommand::with_name("...")
      • stratact
        gotcha
      • arunkumar413
        B= Fn get_reference(a){&a}
      • Yaniel
        so you write a function that does &a for you so you don't have to do &a yourself?
      • seriously?
      • arunkumar413
        Is it same as writing B=&a
      • Yaniel
        and no it's not the same
      • arunkumar413
        Ya
      • moltonel joined the channel
      • Yaniel
        because in rust a would be destroyed at the end of get_reference
      • arunkumar413
        Because I don't remember what symbols does after switching few languages
      • Yaniel
        & and :: are pretty much universal in meaning
      • jperras joined the channel
      • jschievink has quit
      • (unless you pull brainfuck into the argument.. but at that point you pretty much deserve any confusion you get)
      • scottmcm
        lol
      • Aqo has quit
      • inad923 joined the channel
      • arunkumar413
        When we use such symbols in a complex expression it becomes difficult to understand what that express does for a new user because of this symbol
      • Where as if use method and function. It would be very clear
      • frehberg has quit
      • zygentoma joined the channel
      • scottmcm
        The problem is that borrowing and ownership is complex, not really that the symbol is complex.
      • Yaniel
        so now you have to remember what get_reference actually does
      • and to understand that you *still* have to know what & does
      • arunkumar413
        No need to remember. It's self explanatory
      • zippity has quit
      • And easy to use in coding
      • Yaniel
        uh no
      • arunkumar413
        Coding should be as close to the real language as possible
      • jperras has quit
      • Yaniel
        nothing prevents me from writing a function save_the_world() that actually formats your hard drive
      • arunkumar413
        Symbols make it looks like mathematics
      • Yaniel
        as self explanatory as the name is
      • arunkumar413
        Not programming language
      • Yaniel
        fun fact, programming tends to involve a lot of mathematics
      • scottmcm
        "arunkumar413> Coding should be as close to the real language as possible" <-- this is demonstrably false.
      • arunkumar413
        We were taught basic maths from childhood it's easy to remember basic symbols such as + - */ etc
      • But programming is not like that
      • ntr joined the channel
      • Yaniel
        by now we should be taught basic programming from childhood too
      • which by your logic would make any programming language convention easy to remember
      • arunkumar413
        They will not know how to name variables
      • Yaniel
        nor functions
      • arunkumar413
        They will come up with more complex sysmbols
      • scottmcm
        arunkumar413: if you don't like naming variables, try something like <https://factorcode.org/>;
      • ryotsu has quit
      • arunkumar413
        Machines will become more human and humans will become machines
      • Aceeri_
        well then why have ambiguity if we become machines anyways
      • ryotsu joined the channel
      • sp1ff joined the channel
      • human languages are shitty and ambiguous and create misunderstandings constantly
      • Yaniel
        (intentionally and unintentionally)
      • ntr
        if i have a function that returns different types or an error based on some conditional match, is that a job for an enum of the return types?
      • as a result