|
Volte posted:throw it on the pile with "never use goto under any circumstances", "only return from a single point", "if (0 == var)" and other such pointless dogmas wish I could goto a reti that early exits your posts
|
# ? Sep 6, 2015 04:08 |
|
|
# ? May 18, 2024 02:19 |
|
also goddamn putting the constant before the variable in a comparison is disgusting
|
# ? Sep 6, 2015 04:21 |
|
fleshweasel posted:single return is nice, but I prefer multiple return statements without mutation to declaring a result variable at the top and mutating it in various places in the body of a function before returning it. agreed, fleshweasel
|
# ? Sep 6, 2015 04:31 |
|
Bloody posted:if the type of the rhs is not obvious from looking at the expression you got bigger problems and in this case using var is specifically discouraged
|
# ? Sep 6, 2015 04:46 |
|
"strong typing is stupid and pointless" - good programmer
|
# ? Sep 6, 2015 05:14 |
|
AWWNAW posted:no it's the new PHP haha gross
|
# ? Sep 6, 2015 10:24 |
|
pepito sanchez posted:"strong typing is stupid and pointless" - good programmer uhh what do you think strong typing is
|
# ? Sep 6, 2015 13:06 |
|
strong typing is when you explicitly write out the full type of everything at least twice, like this:code:
|
# ? Sep 6, 2015 13:36 |
|
wait you're taking the piss nm
|
# ? Sep 6, 2015 13:50 |
|
strong typing is when you prove your superiority as a coder by wrestling the compiler into submission
|
# ? Sep 6, 2015 14:14 |
|
Soricidus posted:strong typing is when you prove your superiority as a coder by wrestling the compiler into submission what's casting in this metaphor, the safe word?
|
# ? Sep 6, 2015 14:36 |
|
Blotto Skorzany posted:what's casting in this metaphor, the safe word? getting into a north south and jamming your balls into the compiler's eyes
|
# ? Sep 6, 2015 15:14 |
|
Bloody posted:uhh what do you think strong typing is maybe i didn't get the point you were trying to make with "if the type of the rhs is not obvious from looking at the expression..." but yeah sometimes it's not because c# and anonymous type returns, and that's when you definitely use var. i was trying to be funny and failed. stop making fun of me, for i am a strong typer
|
# ? Sep 6, 2015 15:22 |
|
strong typing is pressing your keyboard keys super hard
|
# ? Sep 6, 2015 15:39 |
|
hackbunny posted:strong typing is pressing your keyboard keys super hard it's me!
|
# ? Sep 6, 2015 15:46 |
|
|
# ? Sep 6, 2015 15:46 |
|
fart simpson posted:strong typing is when you explicitly write out the full type of everything at least twice, like this: no that's just called lots of typing
|
# ? Sep 6, 2015 19:22 |
|
rjmccall posted:reference-initialization can bind to objects of subclasses, but assignment is resolved statically is there a compiler setting in gcc or clang that will warn if you try to assign a subclass to a reference?
|
# ? Sep 6, 2015 19:56 |
|
FamDav posted:is there a compiler setting in gcc or clang that will warn if you try to assign a subclass to a reference?
|
# ? Sep 6, 2015 20:19 |
|
Ralith posted:Assuming you mean "initialize a reference with an object whose type is a subclass of the referenced type," no, for the same reason there's no warning if you try to upcast a pointer. It's a safe and normal thing to do. no, i mean assignment why would i mean initialization
|
# ? Sep 6, 2015 23:54 |
|
FamDav posted:no, i mean assignment what you do in your own ide in private is your own business, were not here to judge
|
# ? Sep 7, 2015 00:00 |
|
FamDav posted:no, i mean assignment
|
# ? Sep 7, 2015 00:49 |
|
i don't know about warning flags but i would guess they don't exist since you can acutally write assignment operators safely for polymorphic types, basically just make operator= virtual in the base class then in each derived class's override try to dynamic_cast the Base& to a Derived& otherwise the advice is generally to disable assignment operators in polymorphic types and make some kind of virtual clone() member that returns pointers so no one can possibly get confused but as long as you think of a = b as really a.operator=(b) for class types, i don't think all this is really confusing. assignment is always resolved statically for the right hand side (and potentially for the left hand side if not virtual) but this is just like every other member function because c++ like most oop languages only has single dispatch. it's a fundamental limitation to c++ polymorphism and something you can't really not be aware of, so assignment working like this ought to feel basically natural and expected Lime fucked around with this message at 00:57 on Sep 7, 2015 |
# ? Sep 7, 2015 00:52 |
|
Ralith posted:because if you meant assignment then that's a perfectly normal operator= invocation on the referenced object and whatever value you're assigning, and whether the lhs is a reference or an object isn't really relevant? simliar to how the lhs being an object vs a reference isn't relevant to any other method call Lime posted:i don't know about warning flags but i would guess they don't exist since you can acutally write assignment operators safely for polymorphic types, basically just make operator= virtual in the base class then in each derived class's override try to dynamic_cast the Base& to a Derived& thats fair, though i feel you could have a warning similar to the non-virtual destructor warning when an assignment occurs and there isn't a non-virtual operator= FamDav fucked around with this message at 02:00 on Sep 7, 2015 |
# ? Sep 7, 2015 01:54 |
|
Is there anything wrong with putting characters like "[" or worse, " ", in an object file symbol name?
|
# ? Sep 7, 2015 02:52 |
|
there are some elf toolchains that explode on symbols that aren't alphanumeric, i don't remember the details mach-o does just fine, it is one of the few ways that mach-o is arguably superior. objc uses symbols like that all the time, including spaces
|
# ? Sep 7, 2015 05:45 |
|
Well, using "gcc" to link and gdb to debug the executable on Linux, I haven't had any problems with any of "[],@# " so far.
|
# ? Sep 7, 2015 06:15 |
|
i was one of those devs that tried to come up with definitive rules on when to use var when it first came out and over time started typing it out of laziness and now i use it literally everywhere the compiler lets me and have never, in years of c# development, ever been confused at what the rhs is doing in a var statement. it's one of those things where if you ask people they all have a strong opinion and yet in practice it doesn't matter at all.
|
# ? Sep 7, 2015 07:47 |
|
you should all write in haskell, where the type remains non-obvious when presented with not only the rhs, but the type itself
|
# ? Sep 7, 2015 08:10 |
|
Sometimes in Haskell the type is clearer if you don't write it. This happens mainly when there's ridiculously generic things going on which have some fairly mundane cases. You see a lot of it in the lens library.
|
# ? Sep 7, 2015 08:45 |
|
Cybernetic Vermin posted:you should all write in haskell, where the type remains non-obvious when presented with not only the rhs, but the type itself i didnt understand Arrows at all until i figured out that the a in "Arrow a" was actually of type "* -> * -> *"
|
# ? Sep 7, 2015 10:31 |
|
imagine reading this with no prior knowledge and then using it in a real program, lol: http://hackage.haskell.org/package/base-4.6.0.1/docs/Control-Arrow.html
|
# ? Sep 7, 2015 10:32 |
|
i like that literally the entire documentation for the type Kleisli m a b is "Kleisli arrows of a monad." and "Beware that for many monads (those for which the >>= operation is strict) this instance will not satisfy the right-tightening law required by the ArrowLoop class."
|
# ? Sep 7, 2015 10:35 |
|
fart simpson posted:i like that literally the entire documentation for the type Kleisli m a b is "Kleisli arrows of a monad." and "Beware that for many monads (those for which the >>= operation is strict) this instance will not satisfy the right-tightening law required by the ArrowLoop class."
|
# ? Sep 7, 2015 11:38 |
|
can someone explain to me what the with\as statement in python is used for? disclaimer: i have had exactly one semester of python
|
# ? Sep 7, 2015 18:14 |
|
Bad Sneakers posted:can someone explain to me what the with\as statement in python is used for? a context manager, so you can execute code on entering and exiting a block. you use as to assign the return/yield value from the context manager. the simplest example is working with a file code:
|
# ? Sep 7, 2015 18:20 |
|
Bad Sneakers posted:can someone explain to me what the with\as statement in python is used for? it basically lets you wrap some code inside an __enter__ and __exit__ step. so imagine you have some code and you want it to execute, but there is some generic setup and teardown code that should be executed before and after it runs. http://effbot.org/zone/python-with-statement.htm
|
# ? Sep 7, 2015 18:21 |
|
Bad Sneakers posted:can someone explain to me what the with\as statement in python is used for? managing the lifetime of things. what is created for a with statement is destroyed at the end. it's for when you do x = open ... try: ... finally: x.close() i've also used with lock(): and with transaction() as t
|
# ? Sep 7, 2015 20:17 |
|
yeah, it's for resources that need to be disposed of when you're done with them like files and DB connections. It's equivalent to the using statement in c#.
|
# ? Sep 7, 2015 20:30 |
|
|
# ? May 18, 2024 02:19 |
|
fart simpson posted:imagine reading this with no prior knowledge and then using it in a real program, lol: you shouldnt really need to use arrows, and if by the time you need them you can't read the source, see Categories are Arrows and read that class' source and be like "oh, i got the gist" then you need to grind in harder on haskell. The language in the documentation for what makes an arrow is annoying though, so implementing your own might suck :/ also, a is not * -> * -> *, even when its the function type. there its * -> *.
|
# ? Sep 7, 2015 21:46 |