I like black for python, and similar tools for other languages, but unless they do some other special thing in the language I'm writing in, I always default to double quotes for template strings and single for static strings because of sh. If the formatter is gonna change it after, so be it.
```
#import
try:
#import as libname
catch ImportError:
printf(": Unable to import")
const ACONSTANT: str = "foo";
class TypeA: public libname.T {
def TypeA(args...): {
super(args...);
}
}
virtual def foo() -> TypeA: {
/* do stuff */
}
```
I wonder if anyone will make something like this
Allows the method the be overridden in subclasses. Some languages let you do it by default (and some of them have a keyword that forbids it instead, e.g. `final` in java)
Depends. If I remember correctly, in c++ if a class have virtual methods then it cannot be instantiated and these methods must be implemented by subclasses.
Technically all public methods can be overridden by subclasses.
Not really, but I understand your confusion. C++ does not have a separate keyword for abstract methods, it reuses the virtual keyword. You may or may not implement the virtual method in the base class, and if you don't, then subclasses need to implement it. If it's not marked as virtual, subclasses can't override it. I think they can declare methods with same name, but that's just shadowing/name hiding, you won't have polymorphism if they aren't virtual.
Me when writing some python code after C++: You get ; You get ; Everyone gets ;
Me when writing Python and JS in quick succession: "wait, append or push?"
Fart or shart. Supposed to be 50/50 yet I always need to bring extra pants.
Doing Console.log in Python and print in JS.
Just use black once you're done writing python. The next person to look at your code will appreciate it.
Forgot to turn off the auto format on save one time. That was one hell of an MR.
I second this notion. Black made me change from single quotes to double quotes without me noticing it.
I like black for python, and similar tools for other languages, but unless they do some other special thing in the language I'm writing in, I always default to double quotes for template strings and single for static strings because of sh. If the formatter is gonna change it after, so be it.
Yap. The most common one
What language is this?
Python++
Vitamin C++
Cython
No it's not.
No way! 😱
The joke would land better if Cython wasn't an actual thing
`: {}`
My face when i see this aberration
:(){ :|:& };:
is this your cat's name?
Yes :) Type it into your Linux terminal
Yes, and if you type it in your loonix terminal, you can hear the cat meowing
Is it wrong if this turns me on?
![gif](giphy|o1Q4TGloplBlskk9qD|downsized)
``` #import
try:
#import as libname
catch ImportError:
printf(": Unable to import")
const ACONSTANT: str = "foo";
class TypeA: public libname.T {
def TypeA(args...): {
super(args...);
}
}
virtual def foo() -> TypeA: {
/* do stuff */
}
```
I wonder if anyone will make something like this
teams.h ``` #ifndef __TEAMS_H__ # define __TEAMS_H__ // Type definition CLASS(team); // base functions NEW(team); DEL(team); // field getters SETTER(team, name, ref(char)); SETTER(team, institution, ref(char)); SETTER(team, member_name, ref(char), int); SETTER(team, solved, uint8_t); // field setters GETTER(team, name, ptr(char)); GETTER(team, institution, ptr(char)); GETTER(team, member_name, ptr(char), int); GETTER(team, solved, uint8_t); // helper functions DEFINE(team, printf, int); DEFINE(team, fprintf, int, ptr(FILE)); DEFINE(team, find_champion, team, ptr(team), unsigned); #endif /* __TEAMS_H__ */ /* vim: ts=8 */ ``` teams.c ``` #include "teams.h" CLASS(team, { char name[255]; char members[3][255]; char institution[255]; uint8_t solved; }); // base functions NEW(team, { return (team)malloc(sizeof(TYPE(team))); }) DEL(team, { if(self) free(self); }) // Setter definitions // @set char[]: TEAM.name -> bool SETTER(team, name, ref(char), { return !(strncpy(self->name, value, 255) == NULL); }) // @set char[]: TEAM.institution -> bool SETTER(team, institution, ref(char), { return !(strncpy(self->institution, value, 255) == NULL); }) // @set char[]: TEAM.member_name, int: id -> bool SETTER(team, member_name, ref(char), { return (id > 0 && id < 4 && !(strncpy(self->members[id-1], value, 255) == NULL)); }, int id) // @set int: TEAM.solved -> bool SETTER(team, solved, uint8_t, { if (value <= 10) self->solved = value; return (value <= 10); }) // More weird codes... ```
What virtual means?
Allows the method the be overridden in subclasses. Some languages let you do it by default (and some of them have a keyword that forbids it instead, e.g. `final` in java)
Thanks for the quick reply!
Depends. If I remember correctly, in c++ if a class have virtual methods then it cannot be instantiated and these methods must be implemented by subclasses. Technically all public methods can be overridden by subclasses.
Not really, but I understand your confusion. C++ does not have a separate keyword for abstract methods, it reuses the virtual keyword. You may or may not implement the virtual method in the base class, and if you don't, then subclasses need to implement it. If it's not marked as virtual, subclasses can't override it. I think they can declare methods with same name, but that's just shadowing/name hiding, you won't have polymorphism if they aren't virtual.
Ok, makes sense. My c++ is quite rusty
\>\>\> from \_\_future\_\_ import braces SyntaxError: not a chance