Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

Generics are dangerous

Name: Anonymous 2018-09-02 12:38

Generics are bad and complex and we should not have them.They make my head hurt. I don’t like complex. I like copying and pasting code and adjusting types. I like macro’s. Just like in 1981. You like generics? You support BUGS in CODE.

Name: Anonymous 2018-09-02 12:45

I like macro’s
I know that you are being ironic, so, I ask of thee, art thou mankind why do you hate macros?
Generics are a subset of macros, in most cases at least. Consider for example:
(define-macro (f t) `(lambda (x : ,t) ...))
and
(define f (lambda (t : *) (lambda (x : t) ...)))

Name: Anonymous 2018-09-02 12:47

Generics are a far evolved typesafe extension of macro’s. Based on the language, they can be closer or more distant from eachother.

Name: Anonymous 2018-09-02 12:51

>>3
Generics are a far evolved typesafe extension of macro’s
No, that would be https://www.ccs.neu.edu/home/stchang/pubs/ckg-popl2017.pdf

Name: Anonymous 2018-09-02 15:40

>>1
>I like macro’s.
Go doesn't have them either(but C has _Generic which allows macros to switch by type, allowing generic macros).

Name: Anonymous 2018-09-02 19:28

>>5
thar’s not C. that’s a gnu extension.

Name: Anonymous 2018-09-02 21:03

>>6
It's in C11, read duh standard

Name: Anonymous 2018-09-02 21:58

I haven't used generics all that much, but would it possible to have limited generics instead of generics being allowed for any types? Like let's say you wanted numeric generics, so you couldn't use blah<String>. You could only have blah<float>, blah<double>, blah<int>, blah<long>, blah<short>, blah<BigInteger> etc.

Name: Anonymous 2018-09-02 22:02

Name: Anonymous 2018-09-02 22:47

>>9
sepples? how about java?

Name: Anonymous 2018-09-03 1:55

>>5
_Generic in C only allows you to implement a shitty version of type switches, letting you implement your own version of ad-hoc polymorphism. It does not help with parametric polymorphism in any way.

>>8
This is what typeclasses are for.

>>10
Interfaces are a limited and shitty version of typeclasses that you can use in java.

Name: Anonymous 2018-09-03 5:30

>>11
parametric polymorphism
Could you explain in C pseudocode what you mean?
I'm not familiar with functional mumbo-jumbo.

Name: Anonymous 2018-09-03 6:06

>>12
The ability to pass types as arguments basically, consider the following:

t id(type t, t value) {
return value;
}


This function takes a type t, then takes a value of type t, and return a value of type t.

Programming languages with type inference also allow you to just write
id(value) {
return value;
}

in which case the compiler automatically fills the correct type.

Both of the above happen during the compile time, so you do not have to worry about safety nor about performance.

Name: Anonymous 2018-09-03 7:01

t id(type t, t value) {
return value;
}
//(type) converts value to type(if same type, unmodified)
#define id(type,value) (type)value

Name: Anonymous 2018-09-03 7:09

The ability to pass types as arguments basically,

Macro arguments can natively pass anything that doesn't have commas in it. Also typeof(value) GCC/Clang extension allows to capture the type passed.

Function arguments can have an enum argument e..g. (DOUBLE,FLOAT,INT,INT64) that can pass types as integer value representing the place in enumeration(the enumeration can hold values for specific struct/class/etc so essentially anything you define). Edited on 03/09/2018 07:11.

Name: Anonymous 2018-09-03 7:11

>>15
yes, you can simulate features of other languages in C. it's because C is turing complete. so is brainfuck

Name: Anonymous 2018-09-03 7:15

Why do people outside of μc still use C? How is that the right tool for the jobb?

Name: Anonymous 2018-09-03 7:16

#define type_idx(T) _Generic( (T), char: 1, int: 2, long: 3, default: 0)

Name: Anonymous 2018-09-03 8:58

>>14
Then you will not be able to do recursion nor pass it as a function argument.

>>15
If you were in lisp (see >>2) this would make sense, except that you are not in lisp, you are in C, where you have to do painful shit like:
MAKEID(char)

...
id_char(1)


enum argument e..g. (DOUBLE,FLOAT,INT,INT64)
Won't work with structs, unions, and function pointers.

for specific struct/class/etc
The specific bit is what causes the issue.
Do you want to end up like glib?

Name: Anonymous 2018-09-03 9:50

>>19
except that you are not in lisp, you are in C
It works when you build you program with macros, not functions. Its just requires typeof/_Generic and some argument selection tricks (in void.h the number of arguments allows nested macro "recursion" limited by argument counter macro).

Name: Anonymous 2018-09-03 9:54

See argcount.h argdetect.h and for type detection with typeof typedetect.h
http://void.wikidot.com/system:page-tags/tag/void2_headers#pages Edited on 03/09/2018 09:54.

Name: Anonymous 2018-09-03 9:57

actually freezing your're are anus is preferable to arguing with FrozenAnus

Name: Anonymous 2018-09-03 10:00

>>21
zOMG! FrozenAnus is back! Have you finished your infinite compression algorithm?

Name: Anonymous 2018-09-03 10:02

>>23
it's not like he just came back. he derailed the game design thread with his retarded opinions about two weeks ago

Name: Anonymous 2018-09-03 10:09

>>24
These opinions are not retarded. I maintain a wiki where its all explained.
http://videogamedesign.wikidot.com/

Name: Anonymous 2018-09-03 10:19

>>25
their're are pretty fucking stupid because they imply that there's one, extremely limited, good way of doing game design. it's super narrow and excludes more or less everything that isn't a turn-based, deterministic, non-narrative game with no action elements. not everything has to be chess, FrozenAnus!

Name: Anonymous 2018-09-03 10:37

>>26
I don't think i advocated for turn-based RPGs, my main focus is the genre of real-time Action RPG with multiplayer/MMO structure(persistent world RPG).
Deterministic RPGs are explored only as concept, for e.g. normalizing damage/spell output from x-y dmg to X.
For things like chance-to-cast X and chance-to-X(e.g.evade chance ) randomness is required.

Name: Anonymous 2018-09-03 11:19

>>26
turn-based, deterministic
These are the only good games though. Well, these plus sandboxes like minecraft.

Name: Anonymous 2018-09-03 12:05

>>28
Its not that i'm against "turn-base determinism" as a concept.
I just don't put it in videogame category:
see FrozenChess series for my "turn-based" ideas.
http://boardgamedesign.wikidot.com/system:page-tags/tag/frozenchess

Name: Anonymous 2018-09-03 13:12

>>28
turn-based
might as well burn your computer and play checkers, faggot

Name: Anonymous 2018-09-03 13:21

>>27
For things like chance-to-cast X and chance-to-X(e.g.evade chance ) randomness is required.
You can use those silly gimmicks in weeb visual novels and rhythm games, you know? Like following a curve with your mouse as close as possible.

Name: Anonymous 2018-09-03 13:25

>>30
Most board games are played over the internet, so that would be an unwise move.

Name: Anonymous 2018-09-03 13:28

>>31
These concepts exist genre-wide, visual novels are using them as RPG elements. I didn't invent them. Chance based attributes and passive chance abilities/spells have been used before even Dungeons and Dragons first edition.

Name: Anonymous 2018-09-03 13:39

For reference DnD evolved from wargaming subtype known as fantasy wargaming.
https://en.wikipedia.org/wiki/Chainmail_(game)

Name: Anonymous 2018-09-03 13:43

>>9
template<typename T>
concept Hashable = requires(T a) {
{ std::hash<T>{}(a) } -> std::size_t;
};

Terrible!

Name: Anonymous 2018-09-03 13:45

>>35
Actually its easier just overload each Hashable type for hash function, without any fancy concepts.
concepts are for high-level design to replace meta-template insanity.

Name: Anonymous 2018-09-03 13:51

>>35
Meanwhile in haskell.
class Hashable t where
getHash :: t -> Int

Name: Anonymous 2018-09-03 13:54

>>33
Randomness ruins the game though. Take a look on wesnoth for example, it is trash for this sole reason.

Name: Anonymous 2018-09-03 14:10

>>38
wesnoth is open source, Make a mod without rng?

Name: Anonymous 2018-09-03 14:14

>>39
I would rather to just make a better game from scratch in a better language.

Name: Anonymous 2018-09-03 14:14

https://github.com/wesnoth/wesnoth/blob/master/src/actions/attack.cpp#L159
You're probably thinking about this?
// Compute chance to hit.
chance_to_hit = opp.defense_modifier(resources::gameboard->map().get_terrain(opp_loc)) + weapon->accuracy()
- (opp_weapon ? opp_weapon->parry() : 0);

if(chance_to_hit > 100) {
chance_to_hit = 100;
}

Don't change these.
Name: Email:
Entire Thread Thread List