[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 368
Thread images: 25

File: hidamari_dpt_waifu2x_traps.png (2MB, 1618x1308px) Image search: [Google]
hidamari_dpt_waifu2x_traps.png
2MB, 1618x1308px
Old thread: >>61442888

What are you working on, /g/?
>>
muslims
>>
File: 1499804168175.jpg (88KB, 1280x720px) Image search: [Google]
1499804168175.jpg
88KB, 1280x720px
>tfw fell for the D meme
>can't be comfortable with any other language in existence because D is so comfy
>peak baby duck syndrome
>>
I have been working on a basic torrent searcher, it scans a few public trackers, and returns results from everyone of them, lets you pick one, and downloads it to the torrent directory.
>>
Can we please talk about programming? Not about anime, religion, or how much you love D
>>
>>61447496
Welcome to the light, friendo.
>>
>>61447529
Nim is the true light, my fello D nigger
>>
>>61447536
Nah, Nim a nice toylang in all but its wildy inferior to D.
>>
>>61447553
thread local GC
>>
>>61447536
D is a myth. Nim is a joke.
>>
>>61447581
C was a mistake
>>
>>61447590
>Keeping track of allocation is HAAAARD :((((
>>
>>61447590
Rust was misguided
>>
>>61447604
>Hard
Tedious*
>>
>>61447606
Java is perfect.
>>
>>61447606
Rust skipped the leg day
>>
>>61447637
That's pretty accurate.
>>61447633
OK pajeet
>>
>>61447575
possible in D.
>>
>>61447661
Name one flaw in Java. You cant.
>>
>>61447670
system.out.print
>>
>>61447581
>Nim is a joke.
I think Nim is going to get its own LLVM compiler
>>61447669
Walter is doing literally nothing, it's like he stopped doing non-boring stuff. I wonder why.

There are some people that want to implement a new GC but that alone will take a heavy rewrite. But that GC is not thread-local
>>
>>61447670
The JVM
>>
>>61447698
ayy, JVM is fucking wonderful
>>
>>61447692
import static java.lang.System.out
>>
>>61447670
Covariant arrays
>>
>>61447670
unsound type system
boxed generics
null references
>>
>>61447694
Who knows, I think theyre currently trying to get the std in order as theyve started deprecating a lot of built-in stuff. D is headed towards optional GC though. Look at all the recent DIPS that are snowballing us there.
>>
>>61447738
arrays are deprecated in favor of collections
>>61447743
all correct which is why I shill haskell
>>
>>61447786
Haskell is also shit.
>>
I wrote a C program that calls printf("%s\n", argv[3]); and then called it with no args and it printed one of my environment variables.

what
>>
>>61447801
liar!
>>
>>61447786
Arrays are the only way to achieve good performance, collections force you to box elements
>>
>>61447670
curly braces
>>
>>61447812
Nice side-effect faggot
>>
>>61447811
On Linux/Posix systems, there is a hidden argument passed to each program: the environment variables, which just happen to live right past the program arguments.
So an acceptable prototype for main is
int main(int argc, char *argv[], char *env[]);

What you're doing is still undefined behaviour, though.
>>
>>61447852
The fact that C will even compile that in the first place is disgusting.
>>
>>61447870
Whycome?
>>
>>61448064
Its UB.
>>
>>61448147
Well yes, but everything in C is UB.
>>
>>61448147
A lot of UB is extremely difficult to detect (possibly undecidable), so the standard does not require compilers to check for it or do anything, really.
>>
>>61448201
and c is shit
>>
>>61448216
It's still the only language usable for FFI.
>>
>>61448233
no
>>
>happily browse programming topics
>find this
https://en.m.wikipedia.org/wiki/Dependency_inversion_principle
Why do people have to put others down like this?
>>
>>61448257
Suggest an alternative that is usable.
>>
>>61448147
I'm very happy C has UB. It'd be such a headache to work around a complex programming language where most things are clearly defined. In C I can just program where things are defined and be explicit where I have to. UB lets the compiler help me out.

And if I want more safety there's plenty of tools for that like https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
For instance.
>>
>>61448338
> i enjoy not filling arguments where theyre needed
>i enjoy tedious edge-case bugs because my compiler doesnt give a shit and i have shitty habits

nah
>>
>>61448338
I wish C would just segfault on UB
>>
>>61448391
See >>61448208
Also, the C standard has no concept of a "segfault".
>>
>>61448422
At runtime then, w/e
>>
File: anko_ehhhh.png (336KB, 477x719px) Image search: [Google]
anko_ehhhh.png
336KB, 477x719px
>>61447496
I feel the same way about using Ruby
>tfw most other languages aren't as comfy as Ruby
>>
>>61448372
Well if you're having serious issues writing simple C code then I don't know
>>61448391
UBSan which I posted has that. Not segfault but it gives an error and line where UB occurred and aborts. I'm sure there's some way to make it break in your debugger instead.

Doesn't catch everything obviously.
>>
>>61448441
>criticizing a language means youre projecting your own incompetence and theres nothing actually wrong

alright m8
>>
>>61448438
>At runtime then
The point still stands, whether it's compile time or runtime.
Consider this piece of UB in C:
> The execution of a program contains a data race
How on earth are you supposed to detect that, runtime or compile time?
>>
>>61448473
But you said you had these issues.
These are not general issues among C programmers so clearly you were bemoaning your situation.
>>
>>61448391

Undefined behavior is not intended to be an error. If it were, it would be defined behavior. Furthermore, not all platforms even have a concept of a segmentation fault to begin with. Dereferencing a null pointer is undefined behavior because while on most platforms, that should result in a segmentation fault, on some, it's a physical address that points to something real, like an interrupt vector table.

The big idea here is that rather than placing runtime requirements to enforce specific behavior, we just let the platform decide how that sort of behavior manifests.
>>
>>61448488
No, i was just giving an example when you program in an environment like C
>>
>>61448524
It's not a language problem that someone makes programming errors out of something which they recognize is a bad habit.
>edge cases
They are something you're aware of when you program in C. It's not as mad as something like C++ where you have people who make a living just being experts in the language without programming.
It's in a pretty nice spot with UB as is. Nothing can be assumed ideal before proven but I'm confident it's scoring high.
>>
>>61444728
>Bernstein disputes that this is a practical attack, arguing that no real-world deployment of qmail would be susceptible.

Now that's what I call Judaism, especially over $500
>>
>>61448591
I just like adhering to purity and contractual consistency. I think a language as wildly uncaring as C has no place in software anymore. But we're stuck with it for decades more.
>>
>>61448653
>feels > reals
Someone's got to write the managers for all these managed languages, and with what?
>>
I want to go through K&R and learn C properly. I used C during some classes when I was in school, but I don't really have a complete understanding of it. What's the standard development setup I should be using under Linux to get started with exercises?
>>
>>61448678
>and with what?
Plenty of better languages can use C.
Unfortunately the prime candidate needs to get rid of its GC first before anyone will think about it.
>>
>>61448678
Agda
>>
>>61448701
vim, gcc, glhf
>>
Why is /dpt/ so slow now? Did all the summer fags leave?
>>
>>61448701
vim, gcc, gnumake, gdb, valgrind, and your favorite terminal multiplexer
>>
>>61448720
>>61449063
>>61448701
I recommend using Clang over gcc simply because Clang has much better error messages than gcc.
>>
where's the gate keeper?
>>
>>61449125
Here

You better have read your SICP today or you may not post in this thread
>>
>>61449150
meme


webdev
>>
>>61449054
They're starting to head out it seems. We had a really high quality thread just yesterday (see >>61425574, it's great save for one troll that showed up towards the very end) for example. Much better than a month ago, at least. Trolls trolling trolls yelling on a daily basis back then.

It's really hard for me to understand what those people even want from their lives. Interesting people rarely respond to trolls because the biggest regulars in /dpt/ know exactly how they work.
>>
Man, package managers sure are great until someone fucks it up and youre stuck unable to do anything.
Guess its toylang night.
>>
>>61449390
learn haskell
>>
>>61449410
Already learning idris, desu.
>>
>>61449422
that's alright but Idris doesn't have great tooling or support desu
>>
File: glitch.webm (1MB, 832x592px) Image search: [Google]
glitch.webm
1MB, 832x592px
>>61447463
I'm working on water for my minecraft clone. Going well.

Thought this glitch was interesting enough to record.
>>
>>61449428
Idris by design is meant to not need a whole debugging suite. And i actually like reinventing the wheel desu.
>>
>>61449467
Is your minecraft clone faster than the original? How is your minecraft an improvement, if at all on the original? Are there any goals you have for your minecraft clone? What language is it written in, C++?
>>
>>61449657
You're about to find out how cool his project is internally. I won't spoil his reveal.

But I'll add that I'm hoping he does some cool user-facing thing with the engine he has once he reaches that stage, like his own version of redstone or something like that. I don't know what his plans are.
>>
>>61449467
>Thought this glitch was interesting enough to record.
You thought wrong
>>
>>61447706
what does this do?
>>
I have a macro that is basically a wrapper around snprintf. However, for reasons, I need to change this so it doesn't use snprintf anymore, probably to something like stringtsream. I need to keep the functionality the same of returning a string without changing the definition.

Is there an easy way to get stringstream to work with a printf style format string, or am I just going to need to parse it and insert all the arguments manually?
>>
File: 1479050699968.jpg (148KB, 953x953px) Image search: [Google]
1479050699968.jpg
148KB, 953x953px
>>61449807
I'll tell you what it doesn't do: compile. Forgot that semicolon, senpai.

With the semicolon, it lets you type
out.println
instead of
System.out.println
to print to the console. Not sure what that anon was trying to accomplish.
>>
>>61449872
cute anime
>>
File: pepe_disgusted.jpg (101KB, 1024x904px) Image search: [Google]
pepe_disgusted.jpg
101KB, 1024x904px
>>61449782
90 percent of the time /dpt/ posts are
>fizzbuzz
>language wars
>syntax arguments

related.

This will probably be the most interesting post ITT i'm calling it.
>>
>>61450096
Not even /agdg/ would care, desu.
Minecraft clones are a diamond dozen.
>>
>>61450096
Stupid frogposter, get suicided
>>
>>61450123
>diamond dozen
kys brainlet
>>
61450161
>falling for the oldest newfag bait
wew
>>
>>61450176
>>61450161
>>
>>61449657
>Is your minecraft clone faster than the original?
I think it will end up being so.

My goal is for the game to be an IDE for writing mods for the game. It's written in C and Scheme
>>
>>61450176
>wew
wew
>>
>>61450351
wew
e
w
>>
>>61450330
>My goal is for the game to be an IDE for writing mods for the game.
u fokn wot
actually that's a pretty cool premise for a game more generally
imagine what if there were a specialized programming language for the mods that also looks kind of like an ancient arcane scroll-language
and like
you must train in-game for higher level ancient scroll magic to write on your scrolls
scrolls = mod packages
>>
>>61449657
>Is your minecraft clone faster than the original?
It's pretty hard to not be. Every minecraft clone is leagues faster than the original.

>>61450330
>Scheme
Okay maybe not.
>>
I've been following: http://higherorderfun.com/blog/2012/05/20/the-guide-to-implementing-2d-platformers/ but I haven't quite gotten it right, there is still issues going on. More in reply.

boolean scantile ( entity_t *ent, int tx, int ty, int h_dir, int v_dir, level_t *map )
{
//tile information
int tile = ( ty * map->Width )+ tx,
til_s = 0,
til_t = map->layer[1].Data[tile];
//tile dimensions
int u = tileset[til_s].tile_w,
v = tileset[til_s].tile_h;
//tile coordinates
int tx1 = tx*u,
tx2 = tx*u + u,
ty1 = ty*v,
ty2 = ty*v + v;
//entity coordinates
int ex1 = (int)ent->hb.x,
ex2 = (int)ent->hb.x + (int)ent->hb.w,
ey1 = (int)ent->hb.y,
ey2 = (int)ent->hb.y + (int)ent->hb.h;
//entity center
int exc = (int)ent->hb.x + (int)(ent->hb.w/2),
eyc = (int)ent->hb.y + (int)(ent->hb.h/2);

int flrL,
flrR;
int celL,
celR;

switch ( til_t )
{
case 1:
flrL = ty1;
flrR = ty1;
celL = ty2;
celR = ty2;
break;
case 2:
flrL = ty2;
flrR = ty1;
celL = ty2;
celR = ty2;
break;
case 3:
flrL = ty1;
flrR = ty2;
celL = ty2;
celR = ty2;
break;
case 4:
flrL = ty1;
flrR = ty1;
celL = ty1;
celR = ty2;
break;
case 5:
flrL = ty1;
flrR = ty1;
celL = ty2;
celR = ty1;
break;
}

float t = (float)(exc-tx1)/ u;
int flrY = lerp(flrL,flrR,t);
int celY = lerp(celL,celR,t);
boolean adjX = false;
boolean adjY = false;

//step x
if ( !adjX && ex2 > tx1 && ex1 < tx1 && flrL < ey2 )
{
ent->pos[0] = tx1 - ent->hb.w;
adjX = true;
}
if ( !adjX && ex1 < tx2 && ex2 > tx2 && flrR < ey2 )
{
ent->pos[0] = tx2;
adjX = true;
}
//step y
if ( !adjY && ey2 > flrY && ey1 < flrY )
{
ent->pos[1] = flrY - ent->hb.h;
adjY = true;
}
if ( !adjY && ey1 < celY && ey2 > celY )
{
ent->pos[1] = celY;
adjY = true;
}
//verify adjustment
if ( adjX || adjY )
{
sethb ( ent );
return true;
}else {
return false;
}
}
>>
>>61450374
I nominate APL.
>>
>>61450374
>>>/v/
>>
>>61450485
what the fuck is this coding style
>>
>>61450485
I originally used h_dir and v_dir so that I only checked for a collision in the corresponding direction. This worked when all the tiles were fully solid, but it does not necessarily work when there are sloped tiles.

I plan on creating a tile definition system later, so that I can have a wider array of slopes, but in the switch statement, you can see that:

1: fully solid tile
2: ascending right 45 degree tile
3: ascending left 45 degree tile
4: descending right 45 degree tile
5: descending left 45 degree tile


From what I have been reading, I need to step x then step y regardless, so I am trying to figure out a way to do that without warping all over the place.

>>61450530
I tried to fit it into the post so I tried t re-style it in a way that I could get the most in
>>
>>61450485
Holy fuck anon. That's serious spaghetti code. I can see why you haven't gotten it right. That's completely unmaintainable.
>but in the switch statement, you can see that
I can't see shit because it's unreadable. There's collision resolution in that code?

>>61450509
Oh god no. I have thought about throwing a forth interpreter in there though.
>>
>>61450545
Anyone with 4CX will just get a scrollbar after a certain point so its fine.
Ricelets need not apply.
>>
File: 1453303319472.jpg (149KB, 1920x1080px) Image search: [Google]
1453303319472.jpg
149KB, 1920x1080px
I'm the person from yesterday who was doing the constraint satisfaction problem (>>61435084 for more context).
I've written my solution: https://pastebin.com/JY0Gvcca
It works and all, but I want to modify it to be "online" in a sense. I want to be able to add and remove males at will, but when recalculating the algorithm, I want it to try and keep the existing males and females matched with each other if it can, and only shuffle things around if it can't.
The total number of males wouldn't actually change, and the females wouldn't preferences wouldn't change, I would just set the males to "does not need to be matched" or something.

For example, with
males = { M1, M2 }
females = { F1. F2 }

F1 accepts { M2 }
F2 accepts { M1, M2 }
F3 accepts { M1 }

The current solution:
M1 matched with F3
M2 doesn't need to be matched.

Then I change it so I do want M2 to be matched.
The current implementation would give:
M1 matched with F2
M2 matched with F1

But the solution I want to pick is:
M1 matched with F3
M2 matched with F1 (or F2, it doesn't matter)

What I'm really trying to do is hotplugging with some hardware, and I don't want to run through the whole algorithm again if a quick solution can be found by keeping most of the shit the same, and if I change the matches between males and females, it will cause a noticeable effect for the users.

Does anyone know how I could add something like this to my algorithm?
>>
>>61450567
It told me I exceeded the limit, so I removed all my comments and spacing I thought wasn't necessary

>>61450566
I removed stuff from the code so I could stay in the post limit.

>There's collision resolution in that code

yes
>>
>>61450605
oh yeah, 2k char limit
>>
>>61448649
It wasn't a practical attack though, considering he's right nobody would go out of their way to assign gigs of memory to qmail on their server, and the overflow didn't result in a priv escape. Crypto breaking money challenges are always bullshit though

That said if even djb can't even write bug free C code literally nobody can. He has a fleet of impressive crypto libraries too but access to them is black box, so careful APIs. A library isn't a network facing program though like qmail so we're all doomed
>>
File: IMG_0036.jpg (796KB, 1536x2048px) Image search: [Google]
IMG_0036.jpg
796KB, 1536x2048px
Why aren't you developing a game /g/? It's fun.
>>
>>61450605
Use pastebin anon. Also I have serious objection to those fucking variable names. And anon, you have structs, don't pull the variables out of them immediately unless there's good reason to. Less typing usually isn't a good reason.
>>
>>61450670
Youre still working on that m8?
>>
I just got a job writing for windows CE
>>
>>61450670
What engine and language?
>>
>>61450713
yeah, in the last couple of months I didn't have time to work on it dud to family issues.

Also, I started from scratch because I've done so many things wrong in the first project.
>>
>>61450670
I have. Plenty of games. But I never feel satisfied with what's done.
I also wanna solve hard problems in UI. like making mobile games fun.
>>
File: 1496605839576.jpg (276KB, 1000x1500px) Image search: [Google]
1496605839576.jpg
276KB, 1000x1500px
>>61450580
you are forgetting 5x other genders
>>
>>61450677

>don't pull the variables out of them immediately unless there's good reason to. Less typing usually isn't a good reason.

I don't mind more typing, but it helped me keep track of what each corner of the tile/entity are. The flrR, flrL, celR, celL are so I could keep track of information inside of the tile, if that makes sense. Do you have any ideas/advice of other ways that might help me keep track of these?

I looked at #4 from that guide
>Scan along those lines of tiles and towards the direction of movement until you find the closest static obstacle. Then loop through every moving obstacle, and determine which is the closest obstacle that is actually on your path.

And I see in the slopes section of that guide when it talks about horizontal movement
>During collision detection (4 above), the slope only counts as a collision if its closest edge is the taller (smaller y coordinate) one. This will prevent characters from “popping” through the slope from the opposite side.

Instead of checking adjX and adjY, I checked whether or not h_dir and v_dir were either greater than 0 or less than 0 (greater going right/down, lesser going left/up). That worked, but that only worked if the tile is solid on all sides.

I should mention that the scantile function is called from a function that only checks for tiles along the entities x axis and in the direction they are going in (from top to bottom), and a similar function for the entities y axis and in the direction they are going in (from left to right).
>>
File: IMG_4138.jpg (377KB, 1167x1536px) Image search: [Google]
IMG_4138.jpg
377KB, 1167x1536px
>>61450737
Swift/Spritekit

>>61450741
Post some of your work anon! I would like to see it
>>
>>61449467
Source?
>>
>>61450789
How is Swift?
I had the idea of wanting to start an OSX VM and play with it.
>>
>>61450580
If your write your output to have a format that could be accepted as input you can simply add a male to the output and insert it again.
If you score matches according to how suitable they are. For instance solo accepting females get their match is highest score, multi accepting females get a lower score (presumably based on the number of mates they can consider). Then you can reevaluate everyone risk free. More discriminating females will keep their mates while the least discriminating females will be the most likely to lose theirs since their score is lower.
>>
>>61450803
I love it, everyone should try.
Swift 4 is almost ready, you should read Apple's documentation to see if you like it:
https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/GuidedTour.html#//apple_ref/doc/uid/TP40014097-CH2-ID1
>>
>>61450871
>let
>let
>let
>letletlet
>letletletlet
>let
>letlet
but that's Rust
>>
>>61450871
Swift sucks by the sole virtue that Apple owns it, which means that they only care Swift with regards to their own ecosystem and nothing else.
>>
>>61450871
Looks alright, is metal still a thing, and how does that work in Swift?
>>
>>61449467
You're writing it in lisp?
>>
>>61450899
Since version 2.2 Swift is free under Apache License
>>
>>61450939
Yeah, but it is hardly cross platform. Why should someone use Swift when Apple only cares about Swift in the Apple ecosystem? It doesn't even support Windows operating systems. Why should someone use Swift when they can use another language like Go or Rust which actually encourages cross platform support?
>>
>>61450893
What's wrong with let again?
>>
>>61450973
what's right with let again?

 let s: String = "hello world".to_string(); 


here's how civilized people initialize a string

 string s="hello world"; 


done!
>>
>>61450973
dynamic-tier trash.
theres no reason to have two separate keywords for declaring a var or enum.
Types are important. But its to be expected from Apple when 90% of their """""""""""programmers"""""""""""""" are code artisans or pajeets.
>>
>>61450923
> is Metal still a thing
yes, too advanced for me tho
>>
>>61451022
>type inference is equivalent to dynamic typing
kys
>>
>>61451022
let != var
>>
>>61451038
-tier != literally
>>61451040
>constant == enum
>>
>>61451008
Because let is the proper way of defining variables
let (x, y, x) = (324,1,45)
>>
>>61451049
it's not alike at all though.
>>
>>61451008
in haskell this is just

s="hello world"
>>
>>61451069
If theres no explicit type in the declaration, its trash.
>>
>>61451067
you can have a keyword for that but it's not a proper way to define variables.
>>
>>61451075
>muh purely functional garbage language

you realize that with object initialization possibilities things get complicated, right?
>>
>>61451079
let niggers =  new List<Nigger>();

The type is in the declaration :3
>>
>>61451049
>type inference is trash
Elaborate.
>>
>>61451095
what is complicated about >>61451075 ?
>>
>>61451040
What's the difference?
>>
>>61451116
in what language
>>
>>61451067
Meanwhile in a sane language.
int num = 1, num2 = 2, num3 = 3; 
>>
>>61451120
In swift. I assumed we were talking swift.
But if you meant something else I'd like to hear that too.
>>
File: water-logic.webm (371KB, 800x608px) Image search: [Google]
water-logic.webm
371KB, 800x608px
>>61450935
Some. Renderer is in C. I JUST got the water logic working right. Been ripping my hair out because I put 0x3 instead of 0x7 for a mask by accident. A sample:
(define (water-potential world state x y z)
(if (equal? water (finite_getneighbor world x y z BOT))
'()
(let* ((cardinals (list LEFT RIGHT FRONT BACK))
(candidates (map list
(map (cut finite_getneighbor world x y z <>) cardinals)
(map (cut finite_getneighborstate world x y z <>) cardinals)
(map (cut neighbor x y z <>) cardinals))))
(if (null? (filter (lambda (e) (and (equal? (car e) water) (> (bit-and (cadr e) #x7) (bit-and state #x7)))) candidates))
(map caddr (filter (lambda (e) (equal? (car e) air)) candidates))
'()))))

(define (water-draining? world state x y z)
(if (equal? water (finite_getneighbor world x y z TOP))
#f
(let* ((cardinals (list LEFT RIGHT FRONT BACK))
(candidates (map list
(map (cut finite_getneighbor world x y z <>) cardinals)
(map (cut finite_getneighborstate world x y z <>) cardinals))))
(print (map (lambda (e) (bit-and (cadr e) #x7)) (filter (lambda (e) (and (equal? (car e) water))) candidates)))
(null? (filter (lambda (e) (and (equal? (car e) water)
(> (bit-and state #x7) (bit-and (cadr e) #x7)))) candidates)))))


(define (water-update! kind world state x y z)
(if (equal? air (finite_getneighbor world x y z BOT))
(place-block! world kind 1 x (- y 1) z))
(when (not (= (bit-and state #x7) 6))
(map (lambda (e) (let-list (x y z) e (place-block! world kind (+ state 1) x y z))) (water-potential world state x y z)))
(if (not (= (bit-and state #x7) 0))
(if (water-draining? world state x y z)
(place-block! world air 0 x y z)))
#f)


All the stuff with underscores, finite_alter, finite_getneighbor, etc, are calls to the renderer.

The water is ugly as fuck right now because I have to modify the water shader to connect the top corners.
>>
>>61451111
just tried to explain to you why it's not that simple in real languages
>>
>>61451124
This is so much better. Very clear association between symbol and value. I'd skip the whitespace surrounding the assignment operator though.
>>
>>61450789
Source?
>>
>>61451124
>claims to be sane
>uses unreadable style
>>
>>61451143
Are you an oop programmer?
>>
>>61451116
in Swift, let creates a constant, while var creates a variable.
>>
>>61451106
Its ambiguous, and enforces that types arent important and eventually youll wish you knew your types by declaration.
Thats why all normal languages eventually decide they want types.

>>61451156
Whats unreadable about that?
>>
>>61451159
Ah. Makes good sense.
>>
>>61451124
>sane
subhuman trash
>>
>>61451143
but it is
>>
>>61451080
How? That's literally math
>>
>>61451160

do 1 line/var like normal people
>>
>>61451124
This is garbage
>>
>>61451170
>can implicitly group variables together AND declare different values
>bad
how
>>61451175
No reason to not take advantage of it, i usually do though out of habit. But it comes in handy a lot.
>>
File: 1470780930550.png (654KB, 800x1280px) Image search: [Google]
1470780930550.png
654KB, 800x1280px
>>61450893
End yourself

>>61451022
>I have no idea what I am talking about.

>>61451038
No such thing as dynamic typing

>>61451079
>I am a retard

>>61451158
He has no idea what he is talking about, even in oop it is easier that way.

>>61451160
>Its ambiguous
No

>and enforces that types arent important
Are you retarded?

>and eventually youll wish you knew your types by declaration.
You do

>Thats why all normal languages eventually decide they want types.
You still have types with type inference.

>>61451124
*Shit language
>>
File: 1465297400484.jpg (100KB, 500x500px) Image search: [Google]
1465297400484.jpg
100KB, 500x500px
>>61451124
???
>>
>>61451160
>ambiguous
That's an error if it is. If it's not, i.e the expression on the rhs has a well known type then its not ambiguous. It's just implicit in the type.
>they want types
You can have type inference and declared types. Often it's how you'd resolve the ambiguity.
>you'll wish you knew your types by declaration
Your editor can make that visible to you if you like. Putting the type there manually is usually just a source of unnecessary editing and edit bugs.
>>
>>61451141
Source? Got a git repo?
>>
>>61451191
>implicit in the type
I meant implicit in the expression.
>>
>>61451184
>conveniently not mentioning my emphasis on explicit types
>>61451190
???
>>61451191
>Your editor can make that visible to you
awful
>>
>>61451173
but computers have to store your shit in a specified number of bits, not "math"
>>
>>61451207
>awful
Motivate.
Notice how you're wasting a lot of time by not making arguments?
>>
>>61451160
>enforces that types arent important
On the contrary, it ensures that types are tracked with full type information and avoids incomplete changes to types during maintenance. At the same time, it has the same degree of type safety as explicit typing.
struct Foo *a = malloc(sizeof *a);
struct Foo *b = malloc(sizeof struct Foo);

Ever wondered why a is the preferred style for mallocing? Because it tracks the type. If a is ever a different struct, it just works. If b's a different struct, you have to make two changes or a bug is introduced. Type inference is the same.
>>
File: 1495122527922.jpg (136KB, 1280x720px) Image search: [Google]
1495122527922.jpg
136KB, 1280x720px
>>61451207
>explicit types
The fuck does that even mean?

>awful
No
>>
>>61451210
>I am a cancerous freak
>>
>>61451210
You mean bytes. Not bits.
>>
>>61451213
And you still havent given an argument to why normal type declaration is bad.
>>61451215
>having an argument based around a shit language thats already filled with redundancy gems like long long
awful
>>
>>61451215
Don't bother arguing with fools. They bring you down to...
Also it's not like he can understand you either way.
>>
>>61451230
bytes are bits too
>>
>>61451155
no
>>
>>61451232
>you haven't given an argument
Except I did. And I don't make unsubstantiated claims unlike you.
Ignored.
>>
>>61451244
No. Bits are an abstraction. Those "bits" you're talking about are actually represented as bytes.
>>
>>61451247
Why?
>>
How do databases delete a record without rewriting the entire table file to disk? This seems like it would become inefficient and rough on hardware when tables start pushing past a few hundred megabytes.
>>
>>61451193
Not yet.
>>
>>61451252
bits are more general you idiot
>>
>>61451232
>redundancy gems like long long
long long was the least-shit solution to their problem of adding a 64-bit type.
>>
File: IMG_4139.png (3MB, 2048x1536px) Image search: [Google]
IMG_4139.png
3MB, 2048x1536px
>>61451273
because it's mine
>>
>>61451276
Why do you think they'd have to?
>>
>>61451286
Do you have a github account so that I can find it when you decide to upload it?
>>
>>61451311
idk, int64 looks better

you can write a script to rename existing int64s in your code base
>>
>>61451298
Look, I don't care what fancy pants academic languages, written by masters students, that you've been using that are built off of abstract machines that aren't representative of real machines.
Like C, for example.

But your "bits" don't actually exist.
>>
>>61451332
>But your "bits" don't actually exist.
but you can change them individually and use them to store data individually
>>
>>61451321
I don't know of any mechanism by which a programming language can instruct the operating system to just chop out sections of a file. Trucate, yes, but deleting bytes X through Y without needing to read the entire file into RAM and write it anew? Doubtful.
>>
>>61451344
Look up mmap.
>>
>>61451332
t b h you sound like a beginner who didn't get to the bitwise stuff yet
>>
>>61447463
Opinions on this lisp?
>>
>>61451342
No. You're just using base 2. You have zero proofs that bits are a thing.
>>
>>61451342
>>61451355

No you can't.
You can access areas of memory of which the fundamental unit is a byte.
You can perform abstract operations that transform words, dwords and qwords.
But bits aren't any more real than doubles.
>>
File: 1484812117137.jpg (36KB, 278x278px) Image search: [Google]
1484812117137.jpg
36KB, 278x278px
>>61451357
I'm fucking retarded, forgot the link.

https://github.com/carp-lang/Carp
>>
>>61451357
it's shit.
>>
>>61451368
cirno a cute
>>
>>61451368
All lisp looks the same to me desu.
no gc is interesting though
Are there any flavors that have ternaries?
>>
>>61451365
>>61451358

I have no proof that I can store and change 8 bits in a byte? I have no proof that bitwise operations are lightning fast? really, there's no way to test this?

you beginners are the dumbest people in the word
>>
File: 1471102981050.png (173KB, 500x281px) Image search: [Google]
1471102981050.png
173KB, 500x281px
>>61451312
This thread is a place where we share our knowledge. If you share binaries, you may not keep the source for yourself. Rather, you must share it with the rest of the thread, in case someone else wants to learn. Therefore, bringing proprietary software to the thread is not permitted, unless it is for legal reverse engineering practice.
Please leave this thread.
>>
>>61451331
There is no guarantee that long long would actually be 64 bits, it's just 64 bits at a minimum, so the name is disingenuous,
The C standards committee tries very hard to not add new keywords unless it's in their "reserved" namespace, so it would have ended up as something ugly like _Verylong.
long long was already being used as an extension by several compilers at the time.
>>
>>61451365
what are you arguing here?
Doubles? what?
>>
>>61451414
This thread is american you commie, take your GPL virus somewhere else.
>>
>>61451416
>There is no guarantee that long long would actually be 64 bits,
I know, that's why int64 would be better
>>
>>61451433
C has stdint.h for that sort of shit.
>>
In, C++, are these two identical?
static_cast<uint8_t>(37)

and
uint8_t(37)

And which should I prefer?
Does static_cast even have any use when the second syntax is much simpler?
>>
File: 1492831891533.png (341KB, 556x561px) Image search: [Google]
1492831891533.png
341KB, 556x561px
>>61451439
Jesus Christ, how do people defend that shit?
>>
>>61451428
>tfw nobody is going to use your shitty non-free virus
>>
>>61451438
c++11 too
>>
>>61451443
You may not like it, but that's what peak performance looks like.
>>
>>61451459
C is peak performance though.
>>
>>61451433
No it would not. There is no guarantee that this is possible in every arch.
>>
>>61451414
kek/10
>>
>>61451413
You have in i386 byte operations. But the only 'bit' operation is usong the carry flag.
>>
>>61451462
>C
>Peak performance
>qsort is twice as slow as std::sort
>>
File: 1477800929393.jpg (16KB, 400x317px) Image search: [Google]
1477800929393.jpg
16KB, 400x317px
>>61451439
#include <stdint.h>
UINT8_C(37)
>>
>>61451413
Can you store and change 8 bits without a byte?
7 bits for instance.
>>
>>61451477
We're comparing languages, not standard libraries.
>Claims C++ is fast
>Doesn't even have restrict pointers
>>
>>61451477
This is bait.
That was just morons who were writing in an environment that didn't have the qsort source so it couldn't inline the comparator function.
Given the same circumstances C++s sort couldn't either.
>>
>>61451439
in that case, I think a C-style cast is appropriate.
>>
>>61451495
Why the fuck does C++ have like 5 different ways to cast shit?
>>
>>61451484
what are you even trying to say you dumbass?

fyi, modern cpus cache more than one
byte at a time but there are still bits
>>
>>61451503
>talking about caching now
holy shit you really don't know how computers don't work do you

i'll explain then
the whole thing is an elaborate troll that I repeat when some faggot comes in and says "it's all just bits", because actually if you took that methodology further you'd say no, it isn't bits, the minimum unit is a byte, and even then a single byte is loaded into a dword or qword register to operate on
>>
>>61451499
it has one way to cast shit, your compiler just adds shit to it when you don't.
>>
File: muh gc.png (531KB, 1138x890px) Image search: [Google]
muh gc.png
531KB, 1138x890px
>>61451462
not anymore.
>>
>>61451499
supposedly it's safer
e.g. you can static_cast a Base* to Derived*, but that won't cast a const Base* to a Derived* or cast unrelated pointers to each other.
It might also facilitate multiple inheritance, since the pointer value needs to be tweaked in such cases. I believe a plain C cast may work as a reinterpret_cast in those cases.
>>
>>61451513
the byte bit is because of minimum memory address (that's what a byte is defined as)
you can't say "grab this specific bit from memory", you can grab a byte and then perform operations on it so as to "set the other bits to 0"
>>
>>61451483
Not the same thing, fucking retard.

>>61451494
>in an environment
Which happens to be all environments where there's a C standard library
>Given the same circumstances C++s sort couldn't either.
It actually can't. It's impossible for std::sort's source to not be available, because it's a template function and therefore must be defined in a header.

>>61451495
C style cast is never appropriate anywhere.
>>61451499
Because legacy C shit.
It doesn't have that many ways to cast stuff, there's 2 main ways to cast stuff in C++ and they have different semantics: static_cast and reinterpret_cast. The former is a typesafe cast while the latter is simply a reinterpretation of the bits.
The second syntax in >>61451439 is not a cast, it's calling the constructor of uint8_t.
>>
>>61451513
the fuck is qword?
d word is "double word" why would your bits be assigned in that?
>>
>>61451532
>Not the same thing, fucking retard.
Literally the same thing.
>>
>>61451368
>https://github.com/carp-lang/Carp

(defn main []
(do (println &"~ The number guessing game ~")
(print &"Please enter a number between 1 - 99: ")
(let [play true

> []
It's not lisp, it belongs to the same group with clojure.
>>
>>61451523
Not her but
No anon you absolutely can't perform operations on bits.
Arguably an &1 operates on one bit but not even that actually operates on a single bit. You operate on bytes or larger. Usually you operate on register size. But there's no modern CPU that operates on bits.
The instructions just aren't there.
>>
File: 1496114727751.jpg (33KB, 400x562px) Image search: [Google]
1496114727751.jpg
33KB, 400x562px
>>61451532
>>61451514
>It doesn't have extra ways to do shit if I just ignore them
>>
>>61451534
>these are the kinds of people trying to say everything is just bits and that i just don't understand

a q word is a quad word

>>61451552
that's why i put it in quotes, but really you can operate on bits and you can operate on strings and complex types, i'm just using the "everything is bits xd" autism against them
>>
>>61451499
Because there's no sane mind behind C++ and multiple lunatics.
>>
>>61451540
No, it isn't you idiot.
>UINT8_C
>Appends the correct suffix to an 8-bit unsigned integer literal.

Is not a fucking type cast you Ctard.
UINT8_C(x) will not compile.
>>
>>61451568
His example was clearly using an integer literal.
>>
>>61451568
>I am a dumb fuck
>>
>>61451559
They're not extra ways to do things, they are deprecated and obsolete ways to do things because C++ is based off C (unfortunately).
>>
>>61451567
they are paid by governments to have fun

the fact that they produce an elaborate clusterfuck doesn't bother them
>>
>>61451581
dynamic_cast and const_cast both exist, are not deprecated and have use cases
>>
>>61451564
>a q word is a quad word
no that's a vlword aka very long word
>>
>>61451543
But clojure is lisp?
Why does having square brackets discount it from being a lisp when the other 99% is clearly lisp?
>>
>people all calling each other dumb
>they're all smart people so it must be true
>the only way to win in /dpt/ is to not participate.
>>
>>61451581
>They're not extra ways to do things, they are deprecated and obsolete ways
Yes they fucking are, you fucking moron. They're in the language, and they compile as fucking valid C++.
Hence, duplicate functionality.
>>
>>61451591
>clojure is lisp
dumb jvm poster.
>>
>>61451575
>>61451579
>Look at me I'm retarded.
You got proven wrong, just fuck off.
>>
>>61451597
>having a feature of Y means you arent X
sasuga
>>
>>61451605
>proves nothing
>ha!!!! I proved you wrong!!! btfo! btfo!!!!!111one!cos(0)
>>
>>61451513
I think you don't know how modern CPUs work

they are not the metaphorical simplified shit that CS retards can handle that was taught by your 80 year old professor emeritus
>>
>>61451559
Look, any language with compiler is the same, it doesn't matter what you write.
It matters what compiler writes.
>>
>>61451592
/dpt/ is just insecure kids who are afraid to speak up in real life to people so they lash out at internet people that are safe.
>>61447463
playing with c# web api and async, decent performance
>>
>>61451614
jesus christ

show me any modern major cpu which can store bits, or operate on bits, NOT operate on large units that in an abstract sense "contain bits"
>>
>>61451622
>it doesn't matter what you write
Yes it does. Extra shit in the language is just more useless cognitive load you have to deal with, especially when dealing with programmers who write in "their" C++ instead of "your" C++.
>>
>>61451627
isn't this exactly your opponents argument, that you CAN load bits into CPU and you CAN perform bit wise operations?
>>
>>61451568
>>61451532
Oh, it was the >hurrr std::sort is slower than qsort guy all along!
Nothing of value here.
>>
>>61451627
Technically jne, cmp, etc operate on single or handful of bits. Technically...
>>
How's my htoi?

unsigned long long htoi(char *s)
{
int i;
unsigned long long n;

n = 0;

for (i=0; s[i]; i++)
s[i] = tolower(s[i]);

if (strncmp(s, "0x", 2) == 0)
s++; s++;

for (i=0; s[i]; i++)
if (!isxdigit(s[i])) return -1;

for ( ; *s; s++, len--) {
if (*s >= 'a' && *s <= 'f')
n = 16 * n + (*s - 87);
else
n = 16 * n + (*s - 48);
}

return n;
}
>>
>>61451636
You can write
uint8_t(37)

then interpreter would come over read it and rewrite it as
static_cast<uint8_t>(37)

will probably even change 37 to binary, and only then compiler is good to go.

Interpreter is there for you not to worry about how and what to write, you can do minimal work.
>>
>>61451665
It's like you didn't read my post at all.
>>
>>61451593
It's not duplicated functionality you retard.
C-style casts do not act the same way as static_cast and reinterpret_cast and dynamic_cast do.
C-style cast is ONLY kept for backwards compatability, it is completely and utterly deprecated and obsolete in C++. Never use it.
It is legacy shit from C, do not use legacy shit from C.

>>61451612
>This damage control
You claimed that UINT8_C was a cast, when it clearly isn't, and therefore is certainly not the same thing.
Fuck off and kill yourself retard.
>>
File: 1469032344868.png (448KB, 846x900px) Image search: [Google]
1469032344868.png
448KB, 846x900px
>>61451568
$ cat main.c && c main.c && ./a.out || echo $?
#include <stdint.h>

int
main (void)
{
uint8_t penis = UINT8_C(37);
return penis;
}
37
>>
>>61451663
>if (strncmp(s, "0x", 2) == 0)
> s++; s++;
You fucked up, bad.
>>
>>61451670
>You claimed that UINT8_C was a cast
>can't read
>>
>>61451552
>But there's no modern CPU that operates on bits.
so what is it operating on? 8 at a time because we became good at miniaturizing electronics but it's still bits
>>
>>61451667
Well, I did read "Extra shit" and wrote my response, there isn't extra shit to this, there is taking away extra shit to make something more convenient is my point of that post.
>>
>>61451636
> Extra shit in the language is just more useless cognitive load
I disagree, I find it informative. If I see a plain C cast, it could mean anything depending on context. If I see a static_cast, dynamic_cast, const_cast or reinterpret_cast it's spelled out plainly and clearly what's going on and what the programmer's intent is.
This is why I don't mind certain operator overloads when they're used tastefully.
>>
>>61451670
>C-style casts do not act the same way as static_cast and reinterpret_cast and dynamic_cast do.
Hence, there are like 5 ways to cast shit.
>C-style cast is ONLY kept for backwards compatability, it is completely and utterly deprecated and obsolete in C++. Never use it.
It's still there, so it counts as duplicate functionality.
>>
Any of you lads work on ARM?
Been thinking about getting a gimmickbox to tinker with.
>>
>>61451671
That's nice, now try it with a variable, idiot.
For your information, uint8_t(x) and static_cast<uint8_t>(x) works with variables because it's an actual fucking (typesafe) cast, unlike UINT8_C which is a completely fucking different thing all together.
>>
>>61451639
You don't seem to understand.
I'll try another angle.

When you have a bool in C++, or one from stdbool in C, what is its size?
Its size is 1 byte. Not 1 bit.


>>61451652
No, "technically" they operate on the size of the register.
In fact those specific examples work with integers and are poor examples, but I get what you mean, and still if you were to adopt the bit position then logically you'd have to refuse that and still go with the byte/word/etc idea.

>>61451696
>8 at a time
You have arbitrarily split up a byte into a fictional smaller unit to make it easier for you to reason about.
There is only one, a byte, and it is being operated on.
You cannot operate on a bit. (again, in this satirical sense)
>>
>>61451670
>It is legacy shit from C, do not use legacy shit from C.
Why bother writing C++ if you're not going to use any of the stuff from C?
>>
>>61451663
It's shit

> s++; s++;
Only the first is executed, learn to indent properly

>n = 16 * n + (*s - 87);
>n = 16 * n + (*s - 48);
These make literally no sense.

>if (!isxdigit(s[i])) return -1;
You are returning a valid value on error.

>s[i] = tolower(s[i]);
Without that you could pass a const char *.

>int i
You want size_t
>>
>>61451684
I was talking about casts, and you just came in here with your dumb UINT8_C macro as if it was even related.
>>
>>61451706
>so it counts as duplicate functionality.
Except it's not duplicated functionality because it doesn't do the same thing.
>>
>>61451716
>When you have a bool in C++
Then you have Int and it's size of it.
>>
>>61451627
> in an abstract sense "contain bits"

what do they contain in reality?

tell the world if it can store more than 2^8 and if bitwise transforms are inefficient, don't hide the real truth you cia nigger
>>
>>61451707
I wrote a small OS in arm64, fun
>>
>>61451701
>it could mean anything depending on context
What a cast is going to do is stupidly obvious.
>>
>>61451708
>That's nice, now try it with a variable, idiot.
The original question did not contain variables.

>>61451724
>I was talking about casts
Nope

In any case, you would not need to use a cast if you used variables, now fuck off.
>>
>>61451719
Compile it dumbass it works
>>
>>61451717
What kind of stupid question is this?
Why the fuck would you ever want to use anything from C in C++ code?
>>
>>61451737
they don't contain anything, they're the fundamental unit of the computer

honestly this is getting really awkward and pointless, it's literally just meant to be a joke to satirise these "just bits"fags but they are actually too stupid to understand
>>
>>61451716
>Its size is 1 byte. Not 1 bit.
1 byte can be 1 bit.

>>61451747
Well, it does not. Kill yourself.
>>
>>61451716
>When you have a bool in C++, or one from stdbool in C, what is its size?


eventually you'll get to bitwise operations, beginner
>>
>>61451748
A better question would be:
Why the fuck would you want to use any of the C++ only garbage?
That language is packed to the brim with garbage and awful design choices.
>>
>some moron brings tons of negativity into /dpt/ again because he's mentally handicapped
We need some barrier to entry. If only 4chan let us encrypt our posts we could have a test and keys that cycle. It'd be great.
>>
>>61451719
>Only the first is executed
*Inside the if, the other is executed anyway and you lose 1 hex digit.
>>
>>61451716
>You have arbitrarily split up a byte into a fictional smaller unit to make it easier for you to reason about.
no, I have empirical proof that that's what it is and how it's treated

> There is only one, a byte, and it is being operated on.
an atom can be split, in that sense we can examine what's a byte
>>
>>61451755
>1 byte can be 1 bit.
No it can't

>>61451756
Holy fucking shit, I am fucking tired of you fucking, you stupid fucking retard.

The entire fucking point is to satirise you, but you're too fucking stupid to see.
Maybe that's why you go with the bit autism, because you think you're smarter than everyone else, even though what you're saying isn't only stupid and deflationary for personal attention, but is actually false by its own logic.

I fucking asked you to do something earlier and you didn't do it.
Store 7 bits, operate on 7 bits, on a modern, major cpu. Not "in" a byte or a word or a dword or similar. JUST 7 bits.
>>
>>61451784
>No it can't
Yes it can, just not in C.
>>
>>61451742

(int *) foo;

Is it removing constness?
Is it reinterpreting an integer as a pointer, or is it just changing one kind of pointer to another? It doesn't tell you anything semantically and it could have a few different effects depending on what foo is. The redundant C++ cast operators are a form of annotating and sanity-checking your code.
>>
>>61451755
>1 byte can be 1 bit.
C guarantees that CHAT_BIT is at least 8, and that char is the smallest type.
sizeof(_Bool) in C is going to be at least 1.
>>
>>61451746
>Nope
Yes I was.
static_cast is a cast, idiot. I clearly had static_cast in my post, which means I'm talking about casts.
And since I was talking about casts, then it implies that it obviously has to also work with variables, otherwise it's utterly useless like UINT8_C.

>>61451759
It's only packed to the brim with garbage if you don't have the brain capacity to understand and use C++ properly.
C++ is powerful, you just need a functioning brain to use it properly.
>>
>>61451663
People who have a brain use strtoull or strtoumax.
>>
>>61451786
We're not talking about obsecure hypothetical and non-existant processors. That would defeat what the bitsters were trying to say anyway.
>>
>>61451800
>then it implies that it obviously has to also work with variables
Nope, learn2logic fag.
>>
>>61451800
C++ is powerful but it's also packed with confusing and contradicting design choices. Many of those are due to its C heritage, many of those are just plain fuckups.
>>
>>61451813
>non-existant processors
Try again.

>>61451798
I was not talking about C.
>>
>>61451796
>Is it removing constness?
Yes. However, use of this pointer may result in UB.
>Is it reinterpreting an integer as a pointer, or is it just changing one kind of pointer to another?
In both cases, it's reinterpreting the underlying bits as the new type. Pointers to different types aren't actually guaranteed to be the same size.
>>
>>61451784
> what you're saying isn't only stupid

that's what a beginner would say

you can't currently explain the nature of bytes in any other way and the scientific theory that it's in reality 8 bits checks out

your problem is that you're too dumb even to troll real science, computer ""science"" fag
>>
>>61451742
It may be obvious, but most of the time in C++ it does something else than what you wanted it to do.
In C, you have no control over wether you want to explicitly reinterpret the bits or safely convert to the other type, if it has a conversion constructor.
>>
>>61451771
Thanks I fixed that
>>61451803
It's an exercise from K&R
>>
>>61451822
>I was not talking about C.
The same applies to C++, except without my typo.
>>
>>61451830
Okay, now fix the rest: >>61451719
>>
>>61451828
But a byte ISN'T always 8 bits, it's system dependent
You've just been thoroughly fucking analihilated

Your bits don't exist, faggot, but you should still shove them up your ass
>>
>>61451836
>C++
Never heard of it.
>>
>>61451848
Consider yourself lucky.
>>
>>61451815
Yes it does.
Just admit that your retarded UINT8_C macro is useless and not the same thing.
I am clearly fucking talking about converting variables, not appending literal suffixes.
>>
>>61451829
>you have no control over wether you want to explicitly reinterpret the bits
That's what a union is for, though.
>>
>>61451857
>Yes it does.
Nope, again, learn to logic.

>Just admit that your retarded UINT8_C macro is useless
Nope, it is actually useful, unlike non-pointer casts.

>I am clearly fucking talking about converting variables
Your example was not. Just admit that you fucked up.
>>
if only you nerds put this much effort into your non-existent projects
>>
>>61451840
Why doesn't the math make sense?
How are you supposed to return an error if the function returns a number?
>>
>>61451816
>confusing and contradicting design choices
Example? because I don't know what you're talking about.

>>61451824
(Bar) Foo()

Should this reinterpret Foo as Bar, or should it call Bar's conversion constructor taking Foo if it has one?
If it does one, how do you instruct it to do the other?
This is why C++ has static_cast, reinterpret_cast, and dynamic_cast.
>>
NEW THREAD

>>61451907

>>61451907
>>
>>61451866
Completely different thing, and more restricting.
>>
>>61451900
>conversion constructor
What the fuck are you going on about? C doesn't have that sort of useless shit.
All of the shit you're describing is just ambiguous and obtuse C++ garbage.
>>
>>61451898
Because you subtract 87 and 48 instead of doing the proper calculations, leading to incorrect results.

>How are you supposed to return an error if the function returns a number?
Either by returning the status or by using a pointer as an argument.
>>
>>61451873
>Nope, it is actually useful, unlike non-pointer casts.
Yeah, because appending a suffix is useful, when you know, you can just add the suffix yourself.
And then you go on the say that non-pointer casts are not useful.
You are severely retarded. You have no idea what you're talking about.
>>
>>61451916
>Completely different thing
How? It's literally for giving the middle finger to the type system and interpreting something bit-by-bit as something else.
C doesn't have retarded amounts of duplicate functionality like C++, so a "reinterpret cast" would be completely unnecessary.
>>
Is read() function atomic on Linux? Does the offset update atomically with the read operation?
I have two threads reading from the same file and I want to avoid race conditions. I want to know if I need a mutex for that.
>>
File: ange.png (585KB, 2000x1519px) Image search: [Google]
ange.png
585KB, 2000x1519px
>>61450096
Did someone say fizzbuzz?!

#include<stdio.h>
int main(){for(int i=0;++i<101;)printf(i%3?i%5?"%d\n":"Buzz\n":i%5?"Fizz\n":"FizzBuzz\n",i);}
>>
>>61451919
>What the fuck are you going on about? C doesn't have that sort of useless shit.
Except we're talking about C++ here you fucking retard.
C++ style casts may be useless in C, but they have a very good reason for being in C++, you fucking retard.
>>
>>61451952
>Is read() function atomic on Linux?
I think it is up to a certain size. 4KB or some shit, but don't quote me on that.
Hunt around in the man pages for a bit.
>>
File: 1472211692378.jpg (370KB, 778x1153px) Image search: [Google]
1472211692378.jpg
370KB, 778x1153px
>>61451937
>you can just add the suffix yourself
How are you supposed to know the proper suffix of the underling type of int[N]_t you dummy?

>And then you go on the say that non-pointer casts are not useful.
Yes, and it is true.

>You are severely retarded. You have no idea what you're talking about.
But I am not you.
>>
>>61451919
>ambiguous and obtuse C++ garbage.
t. brainlet
Fucking educate yourself, braindead Ctard.
>>
>>61451955
>but they have a very good reason for being in C++
Attempting to fix the other terrible design decisions in the language? So like 95% of all C++ features?
>>
>>61451938
Except a union and a typecast is not the same thing.
I shouldn't have to argue this.
Just stop.

>Want to reinterpret something as something else
>Have to change the definition of the union
Yeah nah, fuck off.
>>
>>61451938
>C doesn't have retarded amounts of duplicate functionality like C++,
except for when it has ooth unions and casts
>>
>>61451972
It's not "fixing terrible design decisions", it's just called making a good and usable language.
Constructors aren't bad design decisions. Being able to explicitly specify what kind of cast you want to do is objectively a good thing.
>>
>>61451963
>Yes, and it is true.
Maybe in a language that is so bad that it doesn't even have constructors.
>>
>>61451953
Oh boy. Here we go.

main(i){for(;i<101;puts(i++%5?"":"buzz"))printf("%i\r%s",i,i%3?"":"fizz");}
>>
>>61452023
lmao
>>
>>61452028
Keep laughing. It won't make you any less of a brainlet Ctard.
>>
>>61451990
>>Have to change the definition of the union
Big fucking deal. It's an anonymous union that's right where it's happening.
This is an operation would wouldn't use a lot anyway.
You can even do this shit on a single line.
#include <stdio.h>

int main()
{
float n = 10.0f;
printf("%ld\n", (union { float f; long l; }){ .f = n }.l);
}


>>61452006
>both unions and casts
Casts work on values, unions work on underlying representations.
Converting a float to a long with a union is going to give very different results than a cast.

>>61452008
>good and usable language
AHAHAHAHAHAHHAHAHAHAHHAHAHAHHAHA
>>
>>61452042
>tfw dumb C++ loser thinks that I am a ctard
lol, k
>>
>>61452053
Absolutely disgusting.
How can you call this language good and usable?

>Casts work on values, unions work on underlying representations.
>Damage control
Just admit you're stupid.
>>
>>61452053

int i;
float f = *(float *) &i;

much more readable than a union
>>
>>61452072
That violates strict aliasing, and is undefined behaviour.
>readable
Make a macro then.
#include <stdio.h>

#define UNION_CAST(val, old, new) ((union { old o; new n; }){ .o = (val) }.n)

int main()
{
float n = 10.0f;
printf("%ld\n", UNION_CAST(n, float, long));
}
>>
>>61452072
int i;
float f = reinterpret_cast<float>(i);

Even more readable, AND not ambiguous.
C++ is just simply better.
>>
>>61452095
we are in agreement
>>
>>61452070
>>Damage control
>Just admit you're stupid.
What the fuck are you going on about?
How am I wrong?
>>
>>61452091
>and is undefined behaviour.
works on every platform under the sun so who cares?
>>
>>61452119
Enjoy optimisations breaking your shit.
>>
>>61452116
You think unions are an acceptable alternative to reinterpret_cast
You are stupid.

>>61452095
int i;
auto f = reinterpret_cast<float>(i);

Fixed.
>>
>>61452129
>You think unions are an acceptable alternative to reinterpret_cast
Honestly, type punning is a pretty shit operation and there are very few legitimate uses for it.
However, unions literally are designed to do type punning.
>>
I'm in love with Yuno!
>>
>>61452145
>and there are very few legitimate uses for it.
I do it all the time in my kernel, for legitimate reasons.
Having to use unions to do it would turn out very ugly and unmaintainable.
Unions are not an acceptable or viable alternative to reinterpret_cast.
In fact, unions are not acceptable in any situation whatsoever.
>>
>>61452167
Oh and to clarify, I only do it with pointers.
reinterpret_cast'ing values is pure evil.
>>
>>61452167
>Having to use unions to do it would turn out very ugly and unmaintainable.
Why? How is >>61452091 "unmaintainable"?
>Unions are not an acceptable or viable alternative to reinterpret_cast.
Why?
>In fact, unions are not acceptable in any situation whatsoever.
>What are tagged unions?
Dumbass.

You need to actually try and back up things you say. You've given literally no reason to believe you.

>kernel
>C++
AHAHAHAHAHAHHAHAHAHAHAHAHHAHAHHAHAHHA
>>
>>61452187
Unless I'm reinterpret_cast'ing a u32 to a pointer, which is perfectly acceptable when you know that the size of pointer is 32bits.
>>
>>61451962
I mean read() does two things: read n bytes from the file and changes file offset by n bytes. If these two operations together are not atomic then I can have a race condition. I know reading the file is atomic up to some value, idk if reading and seeking done by read() are atomic together.
>>
>>61452203
>reinterpret_cast'ing a u32 to a pointer
You're fucking retarded.
>>
>>61452200
>>What are tagged unions?
you mean std::variant? Yes, I love it.
>>
>>61452200
>>What are tagged unions?
Something C doesn't have, and are very useful. Too bad C doesn't have them.
C++ however has std::variant which is a type-safe tagged union.

>How is >>61452091 "unmaintainable"?
Because it uses C macros, and C macros are never acceptable.

>>kernel
>>C++
>AHAHAHAHAHAHHAHAHAHAHAHAHHAHAHHAHAHHA
Yeah, believe it or not, C++ is perfectly suitable for kernel development.

>>61452218
It's perfectly fine when you know that the size of a u32 is the same size of a pointer.
I know that I do it in my page table code somewhere.
>>
>>61452253
>Something C doesn't have, and are very useful. Too bad C doesn't have them.
They are completely trivial to implement in C. Again with C's lack of useless duplicate functionality.
Why do you need some special garbage when you can make it from a struct, a union, and an enum?
>Because it uses C macros, and C macros are never acceptable.
i.e. "I am a retard with no arguments".
>Yeah, believe it or not, C++ is perfectly suitable for kernel development.
Said no serious kernel developer, ever.
>It's perfectly fine when you know that the size of a u32 is the same size of a pointer.
You're seriously stupid. Someone this retarded shouldn't be making a kernel, or any program in general.
Why would you make such retarded assumptions when a standard type for this exact thing exists?
>>
>>61452291
>Why do you need some special garbage when you can make it from a struct, a union, and an enum?
what do you think std::variant is built out of?
>>
>>61452291
>They are completely trivial to implement in C. Again with C's lack of useless duplicate functionality.
Can you make it completely typesafe? Can you make it work with any number of arbitrary types? No? Well that's too bad, C++ can.

>Said no serious kernel developer, ever.
What a stupid argument.

My toy kernel only runs on i686. It is perfectly fine to assume that the size of a pointer is 32bits because in 100% of cases it is.
Of course I wouldn't do it if the size of a pointer could be different.
>>
>>61452347
>>Said no serious kernel developer, ever.
>What a stupid argument.
>My toy kernel only runs

kek
>>
rewrite everything in Rust you cunts
>>
>>61452898
not until my blue hair dye and choker arrives
>>
>>61452898

How about you start? I'm certain a few language interpreters could be rewritten in Rust.
>>
>>61453014
imagine LLVM rewritten in Rust
>>
>>61453803
Idiot.
>>
>>61453956
umad
Thread posts: 368
Thread images: 25


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.