/dpt/ - Daily Programming Thread

Old thread: What are you working on Sup Forums?

Other urls found in this thread:

youtube.com/watch?v=TzAjEIMqkAo&list=PL2dAOzo3a1SqxkO_c7mVzUcQh5leLHjsX&index=1
boards.Sup
github.com/Maldaris/spring-model-generator
port70.net/~nsz/c/c11/n1570.html#6.5p7
libsdl.org/projects/SDL_net/docs/SDL_net_frame.html
youtube.com/watch?v=iJfC4-yNnzY
twitter.com/NSFWRedditImage

?????????????????????????????????????????????????????????????????????????

BLOWN THE FUCK OUT

>Cast something to char *
>It magically aliases with everything else
I think any compiler would be smart enough to know that it only aliases what you casted from.
int fill(int *restrict x, float *restrict y) {
*x = 1;
*y = 0.5;
return *(char *) x;
}
The char * couldn't possibly alias y.

it's different when you use restrict, otherwise it's not allowed to assume that it doesn't alias anything besides what you casted from

...

kys

>the char* can alias both x and y
it can alias x OR y
>not allowed to be reordered
they are
>char* might alias y
it aliases x, as it's obvious from the code
>would be incorrect to reorder
the standard allows it
it's undefined behavior
>irrelevant
aliasing rules are irrelevant? were you dropped?
>for the same reason as here
those can be reordered because there's no dependency between i and f
>BLOWN THE FUCK OUT
no, this is BTFO:

go ahead and tell that to the gcc devs then, chump

>it's undefined behavior
No it's not. Sure, he's not calling the function correctly, as he should be using the members, but C11 allows you to read union members that wasn't the last one written to.

what? that the "literate" fag can't read a 3 line function? which one of the points do you object to and what are your arguments besides "gcc does it like this"?

>trying to get F# to run in Monodevelop
>error during plugin installation, even though I did every step as described in their manual
>try to run it anyways, and manage to open a new file with working syntax highlighting and tab completion
>doesn't compile inside Monodevelop
>some random dude from 2014 had the same issue
>it got closed without being solved
>TWO FUCKING YEARS AGO

so this is why nobody uses F#.

>No it's not.
don't make definitive statements when you don't know what you're talking about because you'll get rekt
>but C11 allows you to read union members that wasn't the last one written to
are you making random statements? because it has nothing to do with why this is undefined

why would you say that when your ass is still bleeding? :^)

I've been up for almost 36 hours now finishing up an opencv program for a competition. I hope it works...

youtube.com/watch?v=TzAjEIMqkAo&list=PL2dAOzo3a1SqxkO_c7mVzUcQh5leLHjsX&index=1

>it's different
no, it isn't: int and float can't alias by default

char* can alias any pointer by default

of course, why would you feel the need to mention it? I said int and float, didn't mention char

the code has a cast to char* you dickbutt

yes, it does; did I say otherwise? what are you trying to say? learn to express your thoughts, muppet

the code behaves differently with/without the restrict keyword, check gcc output if you don't believe me

use vscode (has intellisense) like everyone else on linux (or vim/emacs)

gcc 5.3 produces same output

gcc 6.1 doesn't
clang 3.8 doesn't
icc 13.0.1 doesn't

Nobody forces them to generate the same code; what does this prove? Do you also know compilers don't always enforce the standard?
>check gcc output
Why is /dpt/ so retarded? Do they know how proofs work?
"integer overflow is undefined"
>no, it just wraps around, check gcc output
"this kind of aliasing is undefined"
>no, it works, check gcc output
"x + x can be anything"
>no, it's always 4, check this example "2+2=4"

>Do you also know compilers don't always enforce the standard?
older versions of gcc didn't enforce the standard in this regard but now it does

import re


url = 'boards.Sup Forums.org/g/thread/54750726/dpt-daily-programming-thread'


def get_base_url():
base_url = re.findall(r'(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}))', url)
print base_url


Anyone know of why this doesn't output the base url but still compiles. It matches with regex101.

>now it does
How do you know? How do you know they haven't actually relaxed the rules to accommodate whiners?

I understand that asm.js is purely for writing the algorithmic part of your application because there's no way to interact with the dom, but how are you supposed to interact with the js part?

Do I have to cook up some shit-tier message passing system?

char* can alias any object, simple as that

Anyone here know how to use SDL_net? I'm following along with a tutorial, but it's not working, and I cannot for the life of me figure out what's wrong.

>it's undefined behavior
No, allocated storage has no declared type.

You are spewing the same unrelated comment over and over again. Yes, char* can alias any object, everyone agreed on this already, multiple times. Answer the actual question if you can.

Finished this for work today when I realized my workload for today was moot because fuckers can't keep LDAP up.

github.com/Maldaris/spring-model-generator

>No, unsigned addition can't overflow.
It has nothing to do with what is being discussed.
int *x = malloc(sizeof *x);
*x = INT_MAX;
*x += 1;

>this code is undefined behavior
>No, allocated storage has no declared type.
See how retarded you sound?

>allocated storage has no declared type
nobody claimed otherwise, you dip

>>No, unsigned addition can't overflow.
>It has nothing to do with what is being discussed.
I know, I never mentioned anything about overflow.

>How do you know? How do you know they haven't actually relaxed the rules to accommodate whiners?
the rule as mandated by the C standard is that char* can alias any object. therefore it is not valid in the code example to simply return the first byte of the int since the char* might alias the float*

hey fags, what's a good book to learn ruby/rails quickly, an intro to RoR, or, at least, to use as reference?

>tfw should have learned ruby/RoR for an interview tomorrow, but didn't do so
FML family

Then why are you calling it undefined behavior?
It's only implementationed defined.

(Me)
>therefore it is not valid in the code example to simply return the first byte of the int since the char* might alias the float*
when the restrict keyword is not being used, i mean

>ruby/RoR
D E P R E C A T E D

also

I'm learning assembly because it seems to be curing my depression.

If I want to make a program to make myself white how would I go about doing that?

>why are you calling it undefined behavior?
Because the call "f(p, p)" aliases a "float*" and an "int*" inside f.

Not a problem.

#! python3
# Sup Forums.org webscraper

import requests, os, bs4

url = 'boards.Sup Forums.org/g/catalog'
os.makedirs('exampleFolder', exist_ok=True)

print('Downloading page %s...' % url)
res = requests.get(url)
res.raise_for_status

catalogSoup = bs4.BeautifulSoup(res.text, "lxml")
catalogElem = catalogSoup.select('#content #threads')

print(len(catalogElem))
print(catalogElem)

if catalogElem == []:
print('Could not find any threads')
else:
for item in catalogElem:
if item.get('class') == ['teaser']:
print(len(item))


Why won't it go further than #threads? I've even tried specifying a specific thread after #threads, but that doesn't return anything. What am I doing wrong with my basic webscraper?

>>ruby/RoR
>D E P R E C A T E D
yeah, well, a job is a job.

same, helps me dissociate and feel calmer and less emotional pain

>a webcuck job of which the technology you're using you learned the day before the interview is an expert programming job

Brainfuck. It's the most powerful language that will ever be invented.

>not valid in the code example to simply return the first byte of the int since the char* might alias the float*
The whole point of the discussion is that the char* doesn't even matter! By the time the dereference through the char* is made, *x and *y were already accessed and those accesses can be reordered because x and y can't alias! That's where the undefined behavior is!

\bhttps?:\/\/[^/]+

>aliasing int* and float*
>not a problem
The standard disagrees with you.

Yeah, you mentioned something equally worthless.

Nope.

they first asked for non-experienced devs, then changed things a bit by asking for a very simple app written in rails
still, perhaps I shouldn't go to the interview... should I?

there is no undefined behavior. it's perfectly valid to cast any object pointer to char* and dereference it.

Yep.

Cite the standard then.

>\bhttps?:\/\/[^/]+
Thank you

this

no, integer overflow is undefined

port70.net/~nsz/c/c11/n1570.html#6.5p7

if char is signed, sure it might be undefined for that reason, but not because of the aliasing stuff

You don't seem capable of understanding it.

char * is compatible with both int * and float *

int* can't alias float* tho

Oh I am, much better than you.

char* can alias either

int* is not compatible with float*

Yes?

Why do you consistently get raped in these threads then?

I don't.

yes

no

What's your point?

Oh, buy you do.

Nope.

that you don't even know what the fuck we're talking about

Yeah.

nice thread

That would be you.
Protip: read that link that posted carefylly again, notice "lvalue expression" then read paragraph 6 above it.

Anyone?

libsdl.org/projects/SDL_net/docs/SDL_net_frame.html
maybe it's just too complex for you tho

this

real thread here

kys

youtube.com/watch?v=iJfC4-yNnzY

That's the tutorial I'm using. My code is nearly identical to that dude's, except when I start up the server, and then start up two copies of the game, the server tells me that the two players are connected, but I only see one player on each copy of the game. I'm trying to make a multiplayer game so obviously I need the players to be able to see each other.

idk lol

int fill(int *x, float *y) {
*x = 1;
*y = 0.5;
return *(char*) x;
}

int fill(int *restrict x, float *restrict y) {
*x = 1;
*y = 0.5;
return *(char*) x;
}

lol! stupid Ctards don't know the difference!

C is the master race

Literally no difference.

$ diff -u /tmp/*.c | less
--- /tmp/1.c
+++ /tmp/2.c
@@ -1,4 +1,4 @@
-int fill(int *x, float *y) {
+int fill(int *restrict x, float *restrict y) {
*x = 1;
*y = 0.5;
return *(char*) x;

yes there is one difference, in the second one, the compiler knows that the char pointer is not equal to y.

Same as the first case: the char pointer is clearly equal to x.

I think what I'm doing wrong is that when a new player joins, I create a new Player object. In his game, he creates an "enemy" object instead. Would it make sense to have a separate class that looks and acts almost exactly like a player, except it's not called a player?

What I think should be happening is that as soon as there's a second player in the server / connection, a new player object should be created and rendered. If that doesn't happen either the second player isn't being created or there's an issue in rendering / network code

if you're not on windows you should be running OCaml anyways

Is it incorrect to say that in Javascript, operators (like +, -, /) are functions?