|
because having to look past the lparen to figure out what the stuff before it means is c++ garbage
|
# ? May 16, 2015 15:55 |
|
|
# ? Jun 11, 2024 23:31 |
|
JawnV6 posted:because having to look past the lparen to figure out what the stuff before it means is c++ garbage :/
|
# ? May 16, 2015 16:22 |
|
Sweeper posted:can someone explain why I can't have both of these methods in rust it wouldnt be so bad if they had allowed default arguments but that apparently got away from them so the workaround is to write a function that takes a trait on tuples but then your code looks like code:
and thats just gross and dumb and is my primary complaint of the language. The other is that you have to write explicit lifetimes for types that need to exist for less than the ones they reference and the compiler is not smart enough to figure this out on its own. conversely C++ compilers cant either but thats why you can delete copy and move constructors so that a type can only exist in the scope its defined. there doesnt appear to be a way to prevent this in Rust and then have it translate to the same meaning. (but that's what the explicit lifetimes are. but you need to then propagate the explicit lifetimes through all trait implementations and that's just a huge pain)
|
# ? May 16, 2015 17:04 |
|
arguments should be part of the name of a method.
|
# ? May 16, 2015 17:07 |
|
fleshweasel posted:arguments should be part of the name of a method. notepad user spotted
|
# ? May 16, 2015 17:55 |
|
fleshweasel posted:arguments should be part of the name of a method. objective-c and swift got this absolutely right and i wish it had caught on in other languages.
|
# ? May 16, 2015 20:26 |
|
huh
|
# ? May 16, 2015 20:55 |
|
fidel sarcastro posted:objective-c and swift got this absolutely right and i wish it had caught on in other languages. Can you explain? Genuinely curious here.
|
# ? May 17, 2015 13:32 |
|
both obj-c and swift have required named parameters (you specify which names are required).code:
code:
this leads to very readable function calls, especially for primitive type parameters. No more doSomething(true, true, false) although Apple does take this a step to far sometimes, requiring writing entire paragraphs for one function call
|
# ? May 17, 2015 15:53 |
|
i refuse to use a language without named parameters java's original sin
|
# ? May 17, 2015 16:21 |
|
M31 posted:both obj-c and swift have required named parameters (you specify which names are required). This is real tight. It also discourages functions with a bajillion arguments since after maybe 3 or 4 arguments the function calls get way too long.
|
# ? May 17, 2015 16:47 |
|
giogadi posted:Can you explain? Genuinely curious here. M31 got it, but it's worth repeating that "required" is the most important part. lots of languages have named parameters, objective-c and swift are the only two i've used that make them a mandatory part of the language.
|
# ? May 17, 2015 16:47 |
|
I'm not sure how I feel about being required to name the parameter in a single parameter function though
|
# ? May 17, 2015 17:05 |
|
fartBoner(gay=itsyou);
|
# ? May 17, 2015 17:09 |
|
small talk leaves the parameter name off when there's only one
|
# ? May 17, 2015 17:14 |
|
the lack of named parameters really bothers me in C and what's worse is that there seems to be a strong "programming paradigm" that is against like packing x, y, z in a coordinate struct because.... that's unnecessary indirection or something? rrrrrrrrrrrt posted:small talk leaves the parameter name off when there's only one nice, smalltalk was the lang made for me
|
# ? May 17, 2015 17:15 |
|
alan kay gave us his only child and we repaid him by using java. smdh
|
# ? May 17, 2015 17:38 |
|
requiring named parameters (instead of just optional) seems like an awful lot of boilerplate static typing w/ a tool that can easily let you see the types and names of parameters if you need to seems better
|
# ? May 17, 2015 18:13 |
|
C# has optional named arguments. If you name your methods sensibly, then it's only really worth it for booleans (so you don't have to make a bunch of dual-valued enums instead). Also sensible IDEs help.
|
# ? May 17, 2015 18:37 |
|
the functions with lots of parameters are exactly those functions that need to have their parameters named.
|
# ? May 17, 2015 19:10 |
|
you can opt out of them in swift, and you have to opt in to the first argument getting one but labels are the right default swift is currently inconsistent about this rule, but we're fixing that
|
# ? May 17, 2015 19:15 |
|
fleshweasel posted:the functions with lots of parameters are exactly those functions that need to be refactored
|
# ? May 17, 2015 19:27 |
|
jokes on you. they will get refactored to "void buttbuttinate(params ButtbuttinateParameters)"
|
# ? May 17, 2015 20:49 |
|
Shinku ABOOKEN posted:jokes on you. they will get refactored to "void buttbuttinate(params ButtbuttinateParameters)" still better tho? i mean, it's kind of silly but if you're passing umpteen params to a function then yeah, maybe they are correlated enough to warrant being an actual object?
|
# ? May 17, 2015 20:59 |
|
if buttbuttinateparameters is reusable then great, otherwise that's kind of gross.
|
# ? May 17, 2015 22:27 |
|
buttinateparams can be good if you are using them as builders instead of structs on the surface builders are lovely hacks to get around not having named parameters, but since they are full objects you can add actual functions take (x, y) versus (r, θ), sure fine take a thing that has a string representation or an actual string? why not &c
|
# ? May 18, 2015 01:06 |
|
of course they'd much much better as a language feature since then you have compile time checks about whether you've given enough data to build a thing and you wouldn't have to write boilerplate
|
# ? May 18, 2015 01:10 |
|
Symbolic Butt posted:the lack of named parameters really bothers me in C C++ code:
|
# ? May 18, 2015 08:06 |
|
Hello all, I am pleased to announce that I am accepting PEP 484 (Type Hints). Given the proximity of the beta release I thought I would get this announcement out now, even though there are some (very) minor details to iron out. (If you want to know the details, it's all at https://github.com/ambv/typehinting) I hope that PEP 484 will be a benefit to all users of Python. I think the proposed annotation semantics and accompanying module are technically sound and I hope that they are socially acceptable to the Python community. I have long been aware that as well as a powerful, sophisticated and "production quality" language, Python is also used by many casual programmers, and as a language to introduce children to programming. I also realise that this PEP does not look like it will be any help to the part-time programmer or beginner. However, I am convinced that it will enable significant improvements to IDEs (hopefully including IDLE), static checkers and other tools. These tools will then help us all, beginners included. This PEP has been a huge amount of work, involving a lot of people. So thank you to everyone involved. If I were to list names I would inevitably miss someone out. You know who you are. Finally, if you are worried that this will make Python ugly and turn it into some sort of inferior Java, then I share you concerns, but I would like to remind you of another potential ugliness; operator overloading. C++, Perl and Haskell have operator overloading and it gets abused something rotten to produce "concise" (a.k.a. line noise) code. Python also has operator overloading and it is used sensibly, as it should be. Why? It's a cultural issue; readability matters. Python is your language, please use type-hints responsibly Cheers, Mark.
|
# ? May 23, 2015 17:43 |
|
basic type checking has worked in pycharm for a while, but the interesting part is that they're standardizing generics so with pep-0484 you could do Python code:
im glad python is the current hipste
|
# ? May 23, 2015 18:36 |
|
Closed Issue: The use of comments to communicate with the type checker #35 https://github.com/ambv/typehinting/blob/master/pep-0484.txt quote:While annotations are normally the best format for type hints, lol
|
# ? May 23, 2015 18:47 |
|
lol magic comments
|
# ? May 23, 2015 18:51 |
|
what are all the languages that are or will give comments semantic meaning golang python
|
# ? May 23, 2015 18:54 |
|
just re-quoting the best part in the section about variable type annotations required to be in comments:quote:If type hinting proves useful in general, a syntax for typing variables may be provided in a future Python version.
|
# ? May 23, 2015 18:58 |
|
comedyblissoption posted:just re-quoting the best part in the section about variable type annotations required to be in comments: isn't that the PEP that coffeetable just posted about being accepted?
|
# ? May 23, 2015 19:01 |
|
it's directly from the PEP https://github.com/ambv/typehinting/blob/master/pep-0484.txt
|
# ? May 23, 2015 19:06 |
|
Bloody posted:lol magic comments magic comments are terrible but I'd rather have type checking via magic comments than not at all, tbh I haven't read through the pep since I'm on my phone but since the type hints appear to be optional could they de-magicify the comments in a later release without causing code to break?
|
# ? May 23, 2015 19:07 |
|
quote:A ``# type: ignore`` comment on a line by itself disables all type checking for the rest of the file.
|
# ? May 23, 2015 19:17 |
|
Arcsech posted:magic comments are terrible but I'd rather have type checking via magic comments than not at all, tbh the type hinting has no effect on how the code is actually run, it's purely for ides and linters
|
# ? May 23, 2015 19:20 |
|
|
# ? Jun 11, 2024 23:31 |
|
suffix posted:the type hinting has no effect on how the code is actually run, it's purely for ides and linters so it's purely decorative? that's helpful.
|
# ? May 23, 2015 19:26 |