[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: 361
Thread images: 18

File: dpt_flat.png (102KB, 1000x1071px) Image search: [Google]
dpt_flat.png
102KB, 1000x1071px
Old thread: >>59914531

What are you working on /g/?
>>
Happy Easter anons.
>>
https://youtu.be/vElZc6zSIXM
>packing indicies and pointers in the same memory to save space because pointers happen to have a couple free bits at the end of them.
This really seems excessive.
>>
Talk to God:

from secrets import choice

with open('/usr/share/dict/words') as f:
words = [word.strip() for word in f]
godwords = ' '.join(choice(words) for i in range(32))

print("\n")
print("God says...\n")
print(godwords+"\n")

>>
>>59919129
Is this divinely inspired?
>>
File: 1462791504718.jpg (52KB, 700x713px) Image search: [Google]
1462791504718.jpg
52KB, 700x713px
>>59919061
Happy Easter!
>>
i'm studying for the programming marathon of this year. doing a lot of hackerrank problems, as well as project euler, reading the entire C programming book and getting together with my teammates to do previous problems from the marathon. we have until September, so i'm optimistic
>>
Is Idris an anime language?
>>
>>59919177
Yes, in honor of the resurrection of our Lord

>blessed
>>
>>59919220
Now do it without a loop statement.
>>
fn main() {
let c = vec![ 15, 21, 8, 4, 10, 11, 31 ];
for d in c {
if d % 2 == 0 {
println!("{} is even", d);
} else {
println!("{} is odd", d);
}
}
}
>>
>>59919269
Nice program anon
>>
>>59919222
No, it's Welsh
>>
>>59919307

thanks
>>
>>59919345
Make another one
>>
>>59919364
>Make another one

then I'm newbies in rust
>>
>>59919074
>This really seems excessive
in the vast majority of contexts, it would be. but when it comes to high-performance shit, cache misses will fuck your shit up. sometimes you gotta do what you gotta do
>>
>>59919269
>>59919307
>>59919345
>>59919364
Your program is not idiomatic enough
fn main() {
println!("{}", vec![15, 21, 8, 4, 10, 11, 31,].iter().map(|n| format!("{} is {}", n, if n % 2 == 0 { "even" } else { "odd" })).collect::<Vec<_>>().join("\n"));
}
>>
>>59919398

nice haha but I think to be starting is illegible that way
>>
File: arthur.png (3KB, 199x190px) Image search: [Google]
arthur.png
3KB, 199x190px
happy easter!

is there a processing-like library for java? i know processing is java but i want to use eclipse.

what i want to do is load an image into a 2d color-array, modify that in some way, and put it back into an image on the harddrive. bonus points for being able to view it in the meantime, but not a concern.
>>
>>59919426
You clearly are too stupid to comprehend Rust's beautiful syntax.
You white males should stick to your stupid languages like C. Us womyn (male) will continue to use our superior languages.
I bet you're the kind of idiot who contirbutes to toxic apps that don't even have a CoC.
>>
>>59919471
>You clearly are too stupid to comprehend Rust's beautiful syntax.
>You white males should stick to your stupid languages like C. Us womyn (male) will continue to use our superior languages.
>I bet you're the kind of idiot who contirbutes to toxic apps that don't even have a CoC.

wtf man
>>
>>59919431
>modify that in some way
like how

>load an image into a 2d color-array
java.awt.image.BufferedImage
>>
>>59919431
i'm pretty sure Java has shit for that kind of thing in its standard library
>>
>>59919494
like pixelsorting or cellular automata

>>59919496
oh okay!
>>
Spent the last hour wondering why 4chan was down.

Turns out my ISP has blocked 4chan, wikileaks, porn websites, warez websites and other moral-panics for the greater good (by returning SERVFAIL for dns lookups). Google DNS it is while I set up my own dns server.

Fucking normies ree.
>>
>>59919684
Don't vote for either of the two major parties unless you want this to continue.
>>
>>59919684

>normies

Vocal minority backed by people in power who see useful idiots for lowering wages and expanding government power.
>>
Guys how hard would it be to build something that

1.scrapes information off ebay like buyer email address + quantity

2a.Creates login details from the browser Webmin of a server by entering 3 different strings and selecting 1 option from a drop down menu
2b. Downloads a string and a zip file.

3. Create an email from a template, enter in scraped Ebay email address + downloaded string + attach zip file.

4. Once email sent, send email, leave feedback and mark as dispatched in ebay.

I know basic bitch programming but not done it in years so don't really know where to start. How hard and length a project would this though and if I were to do it what languages and programs would I need to be up to speed with?

The only program I am any good with is excel...
>>
I hate error handling.
>>
How does one learn (T)SQL in the correct order? I am self learner and i started with C#. I have found few very good C# books and i learn from those. I wanted to get familiar with SQL and i can't seem to pinpoint the Go-to book when it comes to databases. In fact, i'm not sure whether i should start with terms like "What is a database" or should directly start with SQL server and syntax.

How do people in universities learn TSQL? What books do you use?
>>
>>59919872
for a noob? pretty hard

Is it really hard? I don't think so

I am self learner in C# and i managed to build my own webscraper that takes the data from a ebay-esque site and stores in a database
>>
>>59919269
void main()
{
import std.algorithm: map, each;
import std.stdio: writeln;
import std.format: format;

[15, 21, 8, 4, 10, 11, 31]
.map!(v => "%s is %s".format(v, v % 2 == 0 ? "even" : "odd"))
.each!writeln;
}
>>
Trying to grab the content of the data-expanded-url attribute. What am I doing wrong? Pls halp

http://jsfiddle.net/GwgDN/64/
>>
>>59919471

Gas chamber
>>
>>59919915
def main():
for i in [15, 21, 8, 4, 10, 11, 31]:
print i,"is odd" if i&1 else "is even"
main()
>>
>>59920104
def main():
print('\n'.join(map(
lambda v: '{} is {}'.format(v, 'odd' if v % 2 == 0 else 'even'),
[15, 21, 8, 4, 10, 11, 31]
)))

if __name__ == '__main__':
main()
>>
>>59919129
import markovify

with open("revelations.txt") as f:
m = markovify.Text(f.read())

print(' '.join(m.make_sentence() for x in range(5)))


$ python god.py
He that leadeth into captivity shall go into captivity: he that sat on the throne and of pearls, and fine linen, and having their breasts girded with golden girdles. And let him hear. But the rest of the Lamb are the seven angels seven golden candlesticks. And I John saw the woman sitteth. The seven stars are the seven churches.
>>
>>59915186
thank you! the syntax is a bit odd for me. i'm used to java
>>
>>59920229
Probably shouldn't have put that in code tags. Here's another.

>And there was found the blood of the voice that spake with me. And whosoever was not found written in the spirit into the wilderness: and I heard a voice from the foundation of the earth opened her mouth, and devoureth their enemies: and if any man have an ear, let him be filthy still: and he that hath an ear, let him that is holy, let him that liveth for ever and ever, The four and twenty elders and the sea, and the heaven departed as a thief, and thou shalt not know what hour I will come on thee as a scroll when it is rolled together; and every free man, hid themselves in the spirit into the air; and there was no more at all. And let him hear what the Spirit saith unto me, Thou must prophesy again before many peoples, and nations, and tongues. And they that dwell on the earth. And he said unto him, Sir, thou knowest.
>>
>>59920229
You gave me an idea, hold on...
>>
hey /dpt/ a game company from my country asked me to write a couple hundred lines of c++ code so they can see my code before hiring me..

but i don't know what to write.. can someone give me some ideas please? something that takes a maximum 500 loc would suffice
>>
>>59920264
Pong?
>>
>>59919806
>>59919808

Yeah, except right now it's ONE party. The other major party and the hanger-on third party both imploded in the last 4 years and haven't a hope.
>>
>>59920264
small database "store"

School with properties like teacher, student, classroom etc and methods add/remove XYZ

bank ATM lookalike
>>
>>59920273
thats a good idea, but im worried that if i use some kind of graphics library it will be harder for them to try it out..

i think they mainly use windows there so i guess i can just use GDI and dont have to worry about anything.

thanks btw
>>
>>59920264
A wayland compositor.
>>
>>59920289
thats a cool idea, and its something i can do without using any external library
>>
>>59919019
Guys wanna ask something.
Is downloading books from libgen safe?
>>
>>59920325
yes

fuck off
>>
how do you go about using a main function in python?
>>
>>59920264
A small C compiler.
>>
>>59920311
You now owe me a beer
>>
>>59920217
too many chars
>>
>>59920343
if __name__ == '__main__':
your_function()
>>
>>59920264
Make compiler that uses hash tables.
>>
>>59920343
def main():
#your code here
>>
>>59920348
>Drinking anything other than water.
Good goyim
>>
So if C - NSA, Rust - CIA what is C++?
>>
>>59920368
>Make compiler that uses hash tables.
the hash table would be for symbol tables?
>>
>>59920360
disgusting
>>
>>59920376
Every good programmer is a heavydrinker
>>
>>59920381
Mossad
>>
>>59920381
Fuckup Beauru of Idiots
>>
>>59920376
Beer is healthier than water in my country
>>
>>59920373
not working
>>
>>59920229
>>59920259
import markovify
import requests

PAGES = range(1, 11)
SENTENCES = 3

def main():
content = []
for page in PAGES:
res = requests.get('https://a.4cdn.org/g/{}.json'.format(page))
if res.status_code == 200:
for thread in res.json().get('threads', []):
for post in thread.get('posts', []):
content.append(post.get('com', ''))

m = markovify.Text('\n'.join(content))
print(' '.join(m.make_sentence() for _ in range(SENTENCES)))

if __name__ == '__main__':
main()


» python shitgsays.py
><br><br>How the fuck wouldn&#039;t&quot; but little did I know, the only way to simply printscrn a selected part of an operating system, but useless by itself; it can only function in the aftermarket. On my L460 it doesnt matter where you have to wind the CRT bulbs by hand, so they stopped making them. How are we supposed to fiddle and tinker with it is scientifically proven that pixel,s8 or any latest android flagship have better cameras.
>>
>>59920396
enjoy
>>
>>59920381
>implying any of the retarded government agencies would be able to grasp such a language
>>
>>59920413
>import markovify

Does markov chains generate a random sentence or what?

how does this sentence makes little sense?
>>
Today i wanna make a simple currency converter, but to add something new I haven't done before or learned yet, I want it to use live update of the currency's values from online. What's the best way to do this? Python btw.

Also pls recommend simple projects for me to complete.
>>
>>59920413
And with cleanup:
import markovify
import requests
from html import unescape

PAGES = range(1, 11)
SENTENCES = 3

def main():
content = []
for page in PAGES:
res = requests.get('https://a.4cdn.org/g/{}.json'.format(page))
if res.status_code == 200:
for thread in res.json().get('threads', []):
for post in thread.get('posts', []):
content.append(unescape(post.get('com', '')).replace('<br>', ''))

m = markovify.Text('\n'.join(content))
print(' '.join(m.make_sentence() for _ in range(SENTENCES)))

if __name__ == '__main__':
main()


>I guess I'll get that.UI looks sorta bad but well, I won't use it as unconfigured, vanilla and straight out of the system that allocates the machine's resources to the other programs that you run. FFFFFFFFFFFFFFFFFFFFFFFF I buy a pass. Reading your chats, it seems to be too much like windows, I still haven't found a way to install the minrmenu in windows 8.1.
>>
>>59920410
>not working

holy shit kill yourself
>>
>>59920448
>Python
>>>/r/abbit
>>
>>59920464
you have to go back
>>
@59920472
Is that what they say at rabbit?
Fuck off, your kind is simply not welcome here.
>>>/r/abbit
>>
to: 59920490
from: 59920496

go back to plebit
>>
Python or Ruby?
>>
>>59920464
Quit being a fag, it's not my fault I listened to the advice that literally everyone gave me, and it'd be retarded to stop now and learn a completely new language before I've even become proficient at this one. Python is pretty simple, so the sooner i hurry up and master it, the sooner I can move on to c++ or some other language
>>
>>59920460
What license is used for this program? I want to save it, modify it or even share modifications of it.
>>
Is it possible to make my SQL server database check for new inputs and if for example value is X, that whole row is sent to client program automatically so that program can show that new row? I doubt something like this is possible, but i still had to ask
>>
∃!59920517
Why do you keep denying being a redditor? Fuck off.

>>59920527
>it's not my fault I listened to the advice
It is precisely your fault. Nobody else is to blame for your retardation. You are responsible for the actions you take.
>and it'd be retarded to stop now and learn a completely new language
It would be retarded to continue with a language that is complete garbage.
>before I've even become proficient at this one
Why would you want to be proficient in using garbage? Seems quite retarded.
>Python is pretty simple
Indeed. And it's also pretty shit.
>the sooner I can move on to c++
C++ is shit itself.
>>
>>59920525
Lisp.
>>
>>59920440
You can use markov chains to generate sentences.

Read in a block of text and see that in that block of text for example the word "a" is followed (%25 of the time by "cat", %25 by "dog" and %50 of the time by "man"). Then you use that to generate random sentences.
>>
>>59920547
Consider it public domain my friend.
>>
>>59920297
Just use something simple like SDL or SFML.
>>
>>59920525
Absolute shit.
>>59920562
Shit.
>>
>>59920583
what about FML?
>>
>>59920527
>it's not my fault I listened to the advice that literally everyone gave me
You were fooled. It seems like you're quite the retard.
>>
>>59920554
In Microsoft SQL you can set a trigger that passes something off to service broker but holy shit you are doing it wrong nigger.

Make the client app poll every few seconds and select any changes. Preferably with an integer identity column, not a timestamp because clockdrift will one day fuck you over.
>>
>>59920525
>Python
>Ruby
>>>/t/umblr

>>59920527
>Python
>C++
>>>/v/
>>
>>59920554
You can try a trigger and use a script inside it.
>>
>>59920561
eat shit redditor.
>>
>>59920525
Perl
>>
>>59920603
>Make the client app poll every few seconds and select any changes

That was my next solution.

How would i enter query that select only new rows, not those that were already selected in the last query?
>>
>>59920586
What language should I use?
>>
>>59920630
I just fucking told you.
SELECT * FROM [Table] WHERE [ID] > @LastIDRecieved
>>
>>59920525
>>59920562
>>59920622
Is this supposed to be a list of shitlangs?
Fine, I'll add some of my own.
C#
J*va
JS
>>
>>59920645
Ruthon
>>
>>59920630
Save insert date into database, get rows that are newer than specified time in your application.
>>
>>59920645
Anything which is not shit would be fine.
>>
>>59920666
Such as?
>>
>>59920647
But what if there are multiple rows (cars for example) and client program only wants BMWs?

>>59920651
This is smart. Maybe i'll go with this. Are there any pitfalls when using time (time chaing in winter/summer etc)
>>
>>59920413
>>59920460
>It would be much lighter. Because 100% of the GNU operating system: the whole system is basically GNU with Windows 10 Pro without messing with android or whatever page aligned btw? Is the text_end thing or whatever in the job market.
10/10 dada
>>
>>59920651
Enjoy having rows vanaish until your app is restarted because of clock drift. Seriously, I've spent ages tracking down bugs because of that shit.
>>
>>59920691
Try with /x/, it generates some lulzy conspiracy theories.
>>
>>59920561
>>59920599
>>59920616
You guys are just being contrarian assholes now. What language would YOU recommend, oh wise, all knowing masters of programming and languages. I suppose you just write in machine language directly because you're real programmersâ„¢
>>
>>59920682
Nigger you dumb.

SELECT *
FROM [Table]
WHERE [Type] = N'Black Mans Wheels'
AND [ID] > @LastIDRecieved

If that's too slow when you have lots of non-BMWs inserted:

SET TRANSACTION ISOLATION LEVEL REPEATABLE READ
BEGIN TRANSACTION
SELECT *
FROM [Table]
WHERE [Type] = N'Black Mans Wheels'
AND [ID] > @LastID
SET @LastID = SELECT MAX(ID) FROM [Table]
COMMIT

Shit nigger, read a fucking book or something
>>
>>59920693
So, i just have to use IDs fro new rows and select those that are higher than last query's ID?

What happens if i have said Car table and client only wants BMWs, finds 3 rows with BMWs in it, how to save the biggest id of those?
>>
>>59920682
Well, that depends on db implementation. I guessvthe simplest solution would be to use UTC.
>>
>>59920714
Every programming language is shit. You will never find a good programming language.
>>
>>59920673
Any language 'x' such that neither of these apply to 'x':
POO
dynamically "typed"
doesn't have a compiler/interpreter
esolang

This isn't a full list, but it's pretty close.
>>
>>59920726
>>59920722

thanks for this, i have never worked with sql before, only know basic shit

i understand the idea now
>>
>>59920726
Not your fucking homework group.
Work it out for yourself.
>>
>>59920693
>Clock drift
Use non shitty time source then
>>
>>59920714
Literally any language is better than Python, pick any of them and it will be better. Then tell me what retarded language you picked so I can be more specific.
>>
>>59920525
Both are decent for scripting. Python has more 3rd party packages, Ruby is comfier. Another one to add to your toolbelt might be Perl since you'll find it on literally every *nix.
>>
>>59920750
If only i had homework, i do this entirely on my own
>>
>>59920767
>Python
>Ruby
>Perl
>"comfier"

>>>/r/abbit
>>
>>59920743
Okay, going to use C.
>>
>>59920784
If you insist. It's by far better than the garbage you have mentioned.
>>
>>59920722
>>59919881
>>
>>59920799
Just kidding, I'm going to use Python.
>>
>>59920807
see >>59920777
>>
>>59920807
>Python
Everything in your posts reeks of reddit.
Seriously: piss off. Your kind is not welcome here.
>>
>>59919074
>>59920423
Who said that?
>>
>>59920758
'm just gonna learn JavaScript instead
>>
>>59920895
Pick any language which is not Python or JavaScript and it will be better.
>>
>>59920752
>Implying your client machine and your server will be synchronized to whatever precision you are using (nanoseconds most likely).

Doesn't matter how good your timesources are if they are on different machines.
>>
>>59920828
>reddit
Wrong. Face it, you're getting this mad over a programming language.
>>59920909
No, I'm going to use Python and JavaScript.
>>
>>59920940
Who the hell are you quoting?
>>
>>59920948
>Python
>JavaScript
>>>/r/abbit
You just confirmed my suspicion that you along with most of this thread are straight from rabbit.
>>
File: dfg.jpg (40KB, 1000x833px) Image search: [Google]
dfg.jpg
40KB, 1000x833px
Imagine you had to implement for example, a compiler, or a ray tracer (something not easy).

Is it wrong to see how other people have done it (for example if i go on github, there are hundreds of projects done in this matter) ?
>>
To the faggot who wants to learn SQL.
Don't. Learn how to use a relational data store first. (i.e. just like use Entity Framework)

Look at what SQL it generates for simple queries. Looks at the DDL it generates for all your tables. You're learning Assembly before you learn what a program is.
>>
>>59920976
Wrong thread.
>>>/g/wdg
>>
If I GPL code can I also sell it to a company so they don't need to be constrained by the GPL in some manner?
>>
>>59920990
>GPL
I don't know if this is a shitpost or retardation desu
>>
>>59920966
Wah! He's using something I don't like! Wahhh!!! I doubt you've written any program worth using. That's why you're here getting this triggered over a programming language.
>>
>>59921017
>Wah! He's using something I don't like! Wahhh!!!
>>>/r/abbit
Leave. Just fucking leave and spare yourself from further embarrassment.
>>
>>59919019
>Bored
>No idea what to do
>>
>>59921017
>Python
>programming language
What was he going to mean by this?
>>
>>59921029
Maybe you should learn how to use >>> correctly, anon!
>>
>>59921003
Yes it's a restrictive licence and that's what my question is about.
>>
>>59920990
Yes, but you can't accept pull requests commits without getting a lawyer involved to assign copyright to you.

Then they will just fork your repo, make their changes on their own copy, and then people will stop using your old outdated version.
>>
I want to know why vi is a superior text editor.
>>
>>59921046
I don't see the word Python in this post. Where could it be?
>>
>>59921041
Whomst was the original source of these phrases?
>>
>>59920971
no it's not wrong
it's helpful to see how people commonly implement things and be able to use those ideas in your projects
>>
>>59921071
In the reply to that post as a quotation of the reply to the reply to that post.
>>
>>59921054
>restrictive licence
I was talking about it being a retarded license, not just restrictive.
>>
If I shouldn't learn python then what should I be learning? Are you faggkts just memeing me? You're quick to shit on everything I say but offer no insights or alternatives, also this board is the only place where I'm told python is shit, everyone else says it's good enough to get started. All memes aside, why is python a waste of time and what would you recommend instead.
>>
>>59921056
>but you can't accept pull requests commits without getting a lawyer involved to assign copyright to you.
Because they own it? I'm not being very clear I guess. What I'm really after is a way to have code publicly available with the constraints of GPL but for me to be able to release people of them for sacks of cash.
>>
>>59921098
Welcome to /dpt/.
>>
>>59921072
Me.

But i posted it under GPL, so feel free to use it as long as you also post it under GPL.
>>
>>59921102
You can release code under whatever licenses you want, even (especially) if they conflict with each other.

What you are suggesting is possible as long as it remains 100% *your* code and you never accept pull requests. If anyone else has a claim you need to lawyer up, not ask 4chan.
>>
>>59921098
python is just babby's first language is all
it's good for hacking together some code or maybe learning programming idioms but for anything serious it's kinda looked down on
>>
>>59921142
Ok. Thanks a bunch.
>>
I can't shake the feeling I'm a 1337 hax0r grill, it's very distracting... it's been a year
>>
>>59921098
>memeing
No wonder a retard like you would even consider learning Python.
Fuck off to your home board
>>>/v/
>>
File: torvalds_contributions.png (12KB, 762x221px) Image search: [Google]
torvalds_contributions.png
12KB, 762x221px
How come Torvalds is always push commits to Git?

Are they finding bugs every day?
>>
>>59921164
I can say with confidence you are wrong.
>>
>>59921098
>but offer no insights or alternatives
Read the thread, there is literally a simple list even idiots like you can use to determine if a language is shit or not.
>everyone else says
I'm assuming you mean on plebbit. You should go back there then. This thread is strictly for discussing programming.
>>
>>59921167
No one in /dpt/ can actually program anyway, so why would you give a shit?
>>
>>59921192
>>59921192
>actually program
As opposed to?
Python (and other garbage similar to it) is simply not programming, there isn't anything "real" or "fake" about it.
>>
Help me /g/

I'm trying to use std:vector with templated types:
vector<BinaryTreeArrayNode<DT>* >* _arr;
BinaryTreeArrayNode<DT*> btn = (*_arr).front();

I get this error:

error: conversion from '__gnu_cxx::__alloc_traits<std::allocator<BinaryTreeArrayNode<int>*> >::value_type {aka BinaryTreeArrayNode<int>*}' to non-scalar type 'BinaryTreeArrayNode<int*>' requested
BinaryTreeArrayNode<DT*> btn = (*_arr).front();


what's going on?
>>
>rust
>python
>javascript

Do you even need any other programming languages?
>>
>>59921172
I know, that's the point ya big dum dum
>>
>>59921213
post the full code retart
>>
>>59921216
Who are you quoting?
>>
>>59921169
>Are they finding bugs every day?
of course. linux is written in C.
>>
>>59921213
>>59921223

I am a retard.
I meant

BinaryTreeArrayNode<DT>* btn = (*_arr).front();

not

BinaryTreeArrayNode<DT*> btn = (*_arr).front();
>>
>>59921242
Anon we're all connected through the warp. You wouldn't understand.
>>
>>59921213
Fuck off with those reddit tier images.
>>>/r/abbit
>>
>>59921262
>Nothing found
What does this mean?
>>
>>59921255
The human brain is capable of many illusions.
>>
>>59921216
>rust
>python
>javascript
>>>/r/CIA
>>>/r/abbit
>>
I want to join a shaolin monestary but instead of martial arts they practice c++ to achieve enlightenment
>>
File: 1481137975137.jpg (145KB, 800x642px) Image search: [Google]
1481137975137.jpg
145KB, 800x642px
Is Rust a dialect of C?
>>
>>59921335
It's a dialect of Fortran, actually
>>
>>59921335
It's a dialect of SJW
>>
File: 1481144220145.jpg (50KB, 720x720px) Image search: [Google]
1481144220145.jpg
50KB, 720x720px
Is Rust a proper subset of C?
>>
>>59919019
>What are you working on /g/?
Writing a quickbar for my game so you can assign items and spells to it, probably the most mundane thing I've worked on so far.
>>
>>59920413

Can you markovify that dpttxt twitter?
>>
>>59921395
Cool.
Post this kind of stuff on >>>/v/ next time though.
>>
>>59921335
>>59921393
Rust is C+ML
>>
>>59921407
No, thanks.
>>
>>59921418
Really? Elaborate.
>>
>>59920460
Can someone explain how this works?
>>
>>59921434
https://en.wikipedia.org/wiki/Markov_chain
>>
>>59921418
>ML
what's ML?

Machine Learning?
>>
>>59921452
>Machine """"Learning""""
>>>/r/abbit
>>
>>59921169
Subscribe to the LKML and see.
>>
>>59921091
Found the BSD cuck.
>>
>>59921484
Mac and Windows must have bugs too , but we don't know because they aren't open-source
>>
>>59921501
Go calm yourself, and maybe tomorrow you'll be able to speak to me properly and respectfully.
>>
>>59921502
But they are, the kernels at least.
>>
>>59921501
>cuck
>>
>>59921431
https://doc.rust-lang.org/reference.html#appendix-influences

Among the biggest influences stated is ML
>>
>>59920966
God just shut up about reddit. Who cares really? You're shitposting about languages you never used.

Time to filter out the string '>>>'
>>
>>59921531
Well, Python could also state that.
What makes it influenced by ML?
>>
What is programming and how do I into it?
>>
>>59921445
retard-friendly explanation? Wiki articles are often too complex, even for simple stuff
>>
>>59921547
>Who cares really?
Anyone not from your website.
>You're shitposting about languages
None of them are languages.

>Time to filter out the string '>>>'
Now it's clear that you are indeed a plebbitor. I recommend you fuck off back to that shithole.

-->/r/abbit
>>
>>59921574
https://simple.wikipedia.org/wiki/Markov_chain
>>
>>59921572
>>>/sqt/
>>
>>59921547
>Who cares really?
So basically you're admitting that you're a redditor then.
>>
>>59921584
There isn't one up?
>>
>>59921512
>>59921530
Nah I'm just gonna take that code you people write and make money off of it without giving you anything in return. It's not like YOU write anything of value, but plenty of BSD cucks do... We love them due to all the free code they make. They even provide free tech support.

Stay deluded... It's great for my bottom line
>>
>>59920264
CHIP-8 emulator
Simple ray tracer for geometric primitives
SNES audio chip simulator
>>
>>59921572
Write down some things to avoid, you will understand and thank me later:
dynamic typing
OOP
>>
>>59921572
Pick a programming language, and learn only the bare minimum about it. Then get on /dpt/, shitpost about the programming language you chose, and take everything personally. Finally, end all your posts with a demand that everyone you argue with returns to reddit immediately.
>>
>>59921169
More like every hour. It's a C project, what else do you expect?
>>
>>59921582
Ok, seems more readable now

How does it translate to program above? It takes random sentences from threads?
>>
>>59921572
1) visit /dpt/ long enough to learn every local meme
2) parrot them
>>
>>59921596
You seem to be upset now and completely incapable of emotion-less productive talk.
>>
>>59921612
i don't know.

how do they know where to find the bugs in a project that big?
>>
>>59921628
Testing, Bugzilla and mailing lists
>>
>>59921634
what if i found a bug in the kernel back in 2009, and it's not fixed after all these years?
>>
>>59920691
>Because 100% of the GNU operating system: the whole system is basically GNU with Windows 10 Pro
kek
>>
>>59921656
File a report in bugzilla or shitpost in the mailing list; optonally post it in lwn
>>
>>59921676
or i could keep it as a personal backdoor
>>
>>59920691
http://kingjamesprogramming.tumblr.com
>>
File: 1459681679932.jpg (49KB, 600x600px) Image search: [Google]
1459681679932.jpg
49KB, 600x600px
>mfw compiling Qt 5.8 on windows
First it was openssl and now nmake is sperging out with error U1095. What is it next, something depend on qtwebengine and no one told me?
>>
>Tfw can verify if you give me +1 that I literally dreamed in code last night
>>
what is this python version autism?
python3 should be a new language
>go to arch linux
>python links to python3
>python2 scripts break
what the fuck
>>
>>59922100
if u use python u should be in the web programming thread. please dont shit up this sthread. tahnks
>>
>>59922100
python2 script.py
>>
>>59922100
Use Java.
>>
>>59922100
That's why you explicitly write #! python2 or python3.
>>
>>59922148
>>59922137

so I'm going through all programs written before python3 became a thing and fix their shebangs? how about no
>>
File: sid meiers pirates.jpg (295KB, 1280x960px) Image search: [Google]
sid meiers pirates.jpg
295KB, 1280x960px
I wanted to make a simple writing app I could use to write a story, just as a fun project. I'd like to make to cross platform so people on mac, linux and windows can all easily use it if I end up making something good.

Is java a good choice for this? Ideally I'd like it to be lightweight, just because software like Word is bloated with crap I'd never use and that irritates me.
>>
>>59922214
> java
> lightweight

No. Use C++ or Rust if you want it to be lightweight.
>>
If you make a c# program that stores data into local db through entity framework and you want to deploy it, would those pcs you install the program there have that localdb or not?
>>
>>59922214
>Is java a good choice for this?
well java certainly is a cross platform language but not really a good choice.
Qt with your favorite language should do the job
>>
Java is the language for making phone apps, right?
>>
>>59922270
Sadly.
>>
>>59922214
You can try tcl/tk, i heard good thing about it if you want a simple gui.
>>
File: 1490222870486.jpg (86KB, 1280x720px) Image search: [Google]
1490222870486.jpg
86KB, 1280x720px
>>59922043
>>59922060
>>59922100
People shouldn't use the quote feature without intending to quote someone, it's considered poor form!
>>
>>59922319
Imaginary quoting is still quoting.
>>
>>59922334
These so-called "imaginary quotes" can't be quotes simply because of their retarded structure.
>>
>>59922319
This is a false rumor. The argument generally goes that it says so somewhere in "the rules," but it actually doesn't say so anywhere in the rules of this board, nor in the rules of 4chan more generally.
>>
>>59922319
Who said this?
>>
In C++: How do I access a member type of a generic type without specifying it's template argument? For example, if you wanted to have a std::vector of it's size_type.

std::vector<std::vector<now what???>::size_type> v;
>>
>>59922375
>This is a false rumor.
It isn't. That symbol has been used in this way for longer than 4chan has existed. Either adapt to its local usage or get the fuck off this site/board.
>The argument generally goes
Didn't read your strawman any further.

>>59922382
Who said what?
>>
>>59922319
People shouldn't post anime images on a technology board, it's considered poor form!
>>
>>59922270
Depends on how you want your phone app to run.

Do you want people to be able to download it from Google Play? Then you use Java.

Do you want people to be able to download it from the iTunes Store? Then you actually use Swift.

Do you want people to be able to download it from the Internet on their computers and then burn it to their bootloaders? Then you use a compiled language, and probably also a preexisting OS code base.
>>
>>59922405
You cannot do that.
>>
>>59921407
Actually /vg/ has a dedicated thread for it.

>>>/vg/174153385
>>
Intended for redditor #59922419 :
Anime is the fundamental part of imageboard culture and being disgraceful to the anime must be a punishable offence. Why not go on any myriad of other sites that better suit your interests?
>>
>>59922405
Just specify a template type or don't be a pussy and use std::size_t
>>
>>59922411
>That symbol has been used in this way for longer than 4chan has existed.
>Either adapt to its local usage or get the fuck off this site/board.
If by "local usage" you mean "how it's used here," as in "how it's used on 4chan," your argument makes no sense. You're telling me that because it has a meaning that predates its meaning here, I should adapt to the meaning it has here specifically. Not only is that a non sequitur -- if you're vouching for the meaning that predates the meaning it has here specifically, you should be telling me to adapt to that meaning, not the latter -- but furthermore, I could tell you the very same, because it seems to be YOU who needs to "adapt to its local usage," seeing as how you're committed to its more universal usage that you can't help but think its local usage is stupid.
>>
I have a arbitrary precision decimal in a string, how do I range check it fits in a C double?

e.g. read from text a Java double (1e309 for example) and check in C if it fits a double.

in C i get
>warning: floating constant exceeds range of ‘double’ [-Woverflow]
>>
>>59922502
post your code you dumb fuck nigger. you posted this yesterday too
>>
>>59922439
>>59922485

my solution

using CppIsAPieceOfShit = int;
std::vector<std::vector<CppIsAPieceOfShit>::size_type> indices{};
>>
>>59922487
>If by "local usage" you mean "how it's used here," as in "how it's used on 4chan,"
I do not.
>your argument makes no sense
Disregarded, this retarded statement is based on incorrect assumptions.

Didn't read any further, by the way. Next time try not to make yourself look like a drooling retard in the first sentence of your post.
>>
>>59922519
I can't. People here might steal it.
>>
>>59922502
http://man7.org/linux/man-pages/man3/strtod.3.html
"If the correct value would cause overflow, plus or minus HUGE_VAL (HUGE_VALF, HUGE_VALL) is returned (according to the sign of the value), and ERANGE is stored in errno. If the correct value would cause underflow, zero is returned and ERANGE is stored in errno."
>>
>>59922519
>you posted this yesterday too
that's because i can't solve the problem.

Also there is no code. i'm trying to cook up a solution

even strtol doesn't work
in C
double min = 1e-324; // minimum value allowed for double in Java
double max = 1e309; // max value allowed for double in Java

>warning: floating constant truncated to zero [-Woverflow]
>warning: floating constant exceeds range of ‘double’ [-Woverflow]

so you read a double from a text file as string and then have to check if it fits the Java ranges for double in C.
>>
>>59922545
yes
using SizeType = std::vector<int>::size_type;
std::vector<SizeType> indice{};


The reason you cannot just use std::vector::size_type is because the template argument T is required for the allocator.
>>
>>59922569
Wow. I believe this is the most retarded post I have ever seen in this thread, and that's saying a lot.
>>
>>59922550
>I do not.
Then you're using the expression incorrectly.
>Disregarded, this retarded statement is based on incorrect assumptions.
And it's your fault that the assumption is incorrect, because the language you used incorrectly reflected your intended meaning.
>>
>>59922569
is there any reason you dont want to use a bigger data type?
>>
>>59922585
?
what do you mean?
>>
>>59922591
>Then you're using the expression incorrectly.
I'm using it correctly.
>And it's your fault that the assumption is incorrect
It's not. You seem to read into stuff too much while attributing false meaning to it.
>because the language you used incorrectly reflected your intended meaning.
Everyone else with a brain begs to differ.
>>
>>59922604
>is there any reason you dont want to use a bigger data type?
what do you suggest?
>>
>>59922550
(cont from >>59922591 ) By the way, regardless, this still holds: >>59922487
>but furthermore, I could tell you the very same, because it seems to be YOU who needs to "adapt to its local usage," seeing as how you're committed to its more universal usage that you can't help but think its local usage is stupid.
The fact of the matter remains that the "local usage" of the > character at the beginning of a line -- local meaning "here," as it should, and not whatever ridiculous thing you intended it to mean -- is to indicate a quote OR an exasperated observation or sarcastic remark.
>>
>>59922651
>this still holds
It doesn't. And considering that your entire post depends on this statement being true, I didn't even bother reading it.
>>
>>59922626
>I'm using it correctly.
You're not. An expression's "local usage" properly means "the way it's used here, particularly as opposed to places outside this place," wherever "here" and by extension "this place" may be.
>>
>>59922629
long double?
alternatively you can make your own. would be a good learning experience
>>
>>59922679
It does though. Nothing you've said has precluded it.
>>
>>59922629

Use a long double.
>>
>>59922043
Well fuck this shit, back 5.6 it is.
>>
>>59922703
>You're not.
I am.
>>59922723
It doesn't, I would even say it contradicts itself, meaning anything that comes after it is entirely worthless.
>>
>>59922731
>>59922711
int main()
{
char a[8] = "1e-324";
char *b;
long double ret = strtod(a,&b);
printf("%Le\n", ret);
return 0;
}


output
0.000000e+00
>>
>>59922760

strtold
>>
>>59922738
An expression's "local usage" properly means "the way it's used here, particularly as opposed to places outside this place," wherever "here" and by extension "this place" may be. This is not the way you used the term, unless in your case "here" is the Internet, in which case you're telling me to adapt to how a > at the beginning of a line is used on the Internet, the implication being that I'm familiar with a usage that comes from *outside* the Internet -- which is nonsense, because a > at the beginning of a line is not generally used outside the Internet in the context of communication.

>It doesn't, I would even say it contradicts itself, meaning anything that comes after it is entirely worthless.
It doesn't though. The fact of the matter remains that the "local usage" of the > character at the beginning of a line -- local meaning "here," as it should, and not whatever ridiculous thing you intended it to mean -- is to indicate a quote OR an exasperated observation or sarcastic remark.
>>
>>59922774
nice

output
>1.000000e-324

i guess i can check if it fits now
>>
>>59922803

Next time, please read the manual.
>>
>>59922814
sorry burger
>>
>>59922258
>>59922258
>>59922258


PLS RESPOND
>>
>>59922870
install gentoo
>>
>>59922870
the pcs would have to have a db installed, obliviously
>>
>>59922843

You should be.
>>
>>59922879
Following question should be, do Win machines have localdb installed on default?

If not, how to make my program install it for them?
>>
>>59922870
I don't know C#. Language agnostic response: Generally no.

Exceptions:
* If you package the DB in its initial state with your application, along with the binaries necessary to interface with those files, the target PC will have the DB.
* If the DB is a part of the target PC's operating system, the target PC will have the DB.

Otherwise, you should use a remote DB.
>>
>>59922905
>do Win machines have localdb installed on default?
no

>If not, how to make my program install it for them?
you have to make a script like git clone .... && and all that jazz
>>
>>59922774
long double
strtold(const char* str, char** endptr) {
str[0] = 'T';
str[1] = 'O';
str[2] = 'L';
str[3] = 'D';
str[4] = '\0';
*endptr = str + 5;
return 1337.0;
}
>>
>>59922914
That's what i assumed, i will probably have to find out how to attach that localdb into my deployed installation
>>
How much of a pain in the ass should I expect hosting git on my own server to be?

Bitbucket has somehow managed to fuck up Recaptcha(I'm using Pale Moon on Ubuntu, and apparently I'm not the only person who has problems), Gitlab apparently can't into backups, and Github charges a monthly fee. So what's the best option if I want private repositories?
>>
File: son_you_fucked_up.gif (425KB, 393x300px) Image search: [Google]
son_you_fucked_up.gif
425KB, 393x300px
>>59922935
>const char*
>[0] =
son me r disapnt
>>
>>59922947
https://www.linux.com/learn/how-run-your-own-git-server
>>
>>59922958
long double
strtold(const char* cstr, char** endptr) {
char * str = (char *) cstr;
str[0] = 'T';
str[1] = 'O';
str[2] = 'L';
str[3] = 'D';
str[4] = '\0';
*endptr = str + 5;
return 1337.0;
}
>>
>>59922947
It isn't a pain in the ass.
On the server, do
git init --bare
in whatever directory, then clone it from your machine.
>>
>>59922980
>declares the string const
>modifies it

how retard are ya?
>>
>>59922947
Fortunately someone's written a few pages on how to do this
https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server
>>
>>59922996
>>59922986
>>59922967
I guess I'll set up my own server, then. Thanks.
>>
>>59922980
>Not
char const *care 
>>
>>59919269
>not 'd in v'
You had one job.
>>
>>59919200
Which marathon, anon?
>>
>>59922994
>muh const correctness

who gives a shit? const gives you exactly zero guarantee of anything in C. you might as well delete that useless documentation keyword. if the memory isn't allocated in a read-only page, it still works, doesn't matter if it was once declared as const in some pointer far away
>>
>>59923034
t. brainlet
>>
>>59919398
>Your program is not idiotic enough
>>
>>59923034
True. C is shit.
>>
>>59920714
>Lisp
>>
>>59923055
>>59923034
>>>/wdg/
>>
File: fuck off.jpg (24KB, 480x360px) Image search: [Google]
fuck off.jpg
24KB, 480x360px
>>59923042

https://ideone.com/GKwLrp
>>
>>59923066
Nice mental gymnastics
>>
>>59923034
>>59923055
>who gives a shit?
>who gives a shit if I screw around with data I expressly promised the providers of said data I wouldn't screw around with?
>who gives a shit if the compiler, taking my promise at face value, may or may not choose to optimize out future memory reads of this variable on account of the fact that it supposedly won't change -- and, as a result, the value of the variable at any given time becomes implementation-defined?
>who gives a shit if my incompetence gets my coworker, who also happens to be my caller, fired?
you fucking soulless monster
>>
>>59922422

C# for unity games which can be deployed to Android and Iphones
>>
>>59923090
>ideone
>>
>>59923112
>Defending the lack of a real read-only data modifier
You're an embarrassment
>>
File: 1480617855065.jpg (483KB, 1920x1080px) Image search: [Google]
1480617855065.jpg
483KB, 1920x1080px
How do you call the feeling when you realize that you could have greatly simplified some function but now that it's done you're too lazy to fix it and the stuff you want to work on next is much more exciting anyway?
>>
>>59923180
paying the technical debt
>>
>>59923112
>I expressly promised the providers of said data I wouldn't screw around with?

nothing is 'promised' in C
anything can be easily casted to anything else

and compiler optimizations are literally not a factor. if GCC starts fucking up, I just compile that function separately with optimizations turned off.

>if the compiler, taking my promise at face value

the compiler is shit then! it'd be crazy to optimize based on a SUGGESTION. that's what const is, really.

>who gives a shit if my incompetence gets my coworker, who also happens to be my caller, fired?

wow that'd be fucking hilarious!

>>59923171
yeah and?
>>
>>59923172
const IS a real read-only data modifier. If you declare a variable as const -- not its destination if it's a pointer type, but the variable itself -- then the compiler is allowed to allocate it in read-only memory. It won't, necessarily -- not if the compiler designers decide it would compromise some kind of efficiency to do so -- but it can.
>>
>>59923238
Kek
int const x = 5;
int wew[x];

Compile that in ANSI C and tell me what c thinks what x is.
>>
>>59923238
>const IS a real read-only data modifier.

dumb shit! you can have a const volatile variable that's "constant" yet can change every single time you read it. how is it read only?

const only matters as far as the original data is concerned. if you declare a string literal, it's likely to be allocated in the object's read-only static data storage section. that's why it's "undefined", because the kernel is going to fucking crash your program if you try to write there.

if you malloc some shit and assign that to a const pointer, then cast the pointer away, C isn't going to give a fuck.
>>
best way to learn scheme?
>>
>>59923197
>nothing is 'promised' in C
Everyone I work with would beg to differ.
>anything can be easily casted to anything else
Yes, and if in doing so you violate assumptions inherent to the way the thing was originally declared, you're doing it wrong.

>and compiler optimizations are literally not a factor. if GCC starts fucking up, I just compile that function separately with optimizations turned off.
>I just compile that function separately with optimizations turned off.
pic related

>the compiler is shit then! it'd be crazy to optimize based on a SUGGESTION. that's what const is, really.
By that logic, the entire C specification is a "suggestion," and it would be crazy to compile code to anything at all. Modifying data initially declared as const, but whose const status has been explicitly cast away, is undefined behavior, and it's no less undefined than any other undefined behavior.

>wow that'd be fucking hilarious!
see: >>59923112
>you fucking soulless monster
>>
>>59923275
5

>>59923292
>dumb shit! you can have a const volatile variable that's "constant" yet can change every single time you read it. how is it read only?
It's not. See what I originally said: >>59923238
>It won't, necessarily -- not if the compiler designers decide it would compromise some kind of efficiency to do so -- but it can.

>const only matters as far as the original data is concerned. if you declare a string literal, it's likely to be allocated in the object's read-only static data storage section. that's why it's "undefined", because the kernel is going to fucking crash your program if you try to write there.
Indeed. See what I originally said: >>59923238
>It won't, necessarily -- not if the compiler designers decide it would compromise some kind of efficiency to do so -- but it can.

>if you malloc some shit and assign that to a const pointer, then cast the pointer away, C isn't going to give a fuck.
It has no reason to care, but it's allowed to. Do you know why it's allowed to? So that people can use const to communicate and enforce their intentions. This is an important and useful function of const.
>>
>>59922319

It's not a quote feature, it's a greentext feature. It is used to contrast from regular text, and nothing more. It can be used for quoting, but it also makes good bullet points, among other things.

>But that's not its original purpose
Doesn't matter.
>>
>>59923297
Learn Common Lisp.
>>
>>59923331
>pic related
oops
THIS pic related
>>
>>59923390

Who are you quoting?
>>
>>59923331
>Everyone I work with would beg to differ.

who cares who you work with? look at the C spec instead. nothing is undefined about casting away const status.

>you're doing it wrong.

nah, if you don't know what the function you're calling does, it's YOU who's doing it wrong.

but you're right about calling it an assumption. it's definitely not a guarantee.

>Modifying data initially declared as const

LOL

a parameter declaration isn't really an "initial declaration". by initial declaration you probably mean definition, which implies resource allocation. it's the caller who does that, the function just allocates a const pointer, i can do anything i want with that pointer, including cast away the const status.

its only undefined if you're actually stupid enough to pass in a string literal there despite having access to the source code... if you get fired for it, that'd probably be the most hilarious thing i've ever seen
>>
>>59923400
Fuck off you nigger-cock sucking fucktarded moron with severe down syndrome.
>>
I have basic programming knowledge in c++ and I'm doing some Qt video tutorials. Is pretty much everything in c++ a pointer? Just like how all objects are reference types in c#?
>>
>>59923356
>He didn't compile it
Strong arguments
>>
>>59923420

Rude.
>>
>>59923428
no
>>
>>59923428
Yes, everything in C++ is a pointer.
>>
>>59923433
I hope I was.
>>
>>59923400

Absolutely no one.
>>
File: 1483909228589.jpg (30KB, 369x318px) Image search: [Google]
1483909228589.jpg
30KB, 369x318px
average = divide . foldl f (0,0) where
divide (s,n) = s / n
f (s,n) x = (s+x,n+1)


There has to be a better way to write this.

average = liftM2 (/) sum length
would be cool if it worked and didn't double-traverse the list.
>>
>>59923429
he doesn't know C despite having 'coworkers', what did you expect
>>
>>59922783
>An expression's "local usage" properly means "the way it's used here
It simply doesn't.
Is this the full extent of your retardation or are you going to make even more ridiculous statements?
Didn't read your post any further.
>>
>>59923403
>nothing is undefined about casting away const status.
YOU look at the C spec. Casting away const status AND THEN MODIFYING THE RESULT is undefined.

>but you're right about calling it an assumption. it's definitely not a guarantee.
It's an assumption intended, by agreement with the creators of the language, to function as a guarantee. If you don't respect this intention, it's YOU who's doing it wrong.

>i can do anything i want with that pointer, including cast away the const status.
And if you do that and then modify the result, it's undefined behavior.

>its only undefined if you're actually stupid enough to pass in a string literal there despite having access to the source code... if you get fired for it, that'd probably be the most hilarious thing i've ever seen
No, actually it's undefined the rest of the time, too. It's not likely to cause a problem, but it's allowed to.

Furthermore, people shouldn't have to examine your source code to make sure it's doing what your declarations tell them it's doing. If that is in fact necessary, you're doing it wrong.
>>
>>59923462
>He doesn't know the ANSI standard
Are you literally 12?
>>
>>59923473
The fact of the matter remains that the usage around here of the > character at the beginning of a line is to indicate a quote OR an exasperated observation or sarcastic remark.
>>
>>59923449
Trash.
>>
>>59923502
why
>>
>>59923524
why
>>
>>59923530
why
>>
>>59923428

No. C++ allows you to declare objects on the stack and perform deep copies when passing them as parameters, if you so choose. In fact, if you are retarded and don't understand the language, you'll end up deep copying everything, since pass by value is the default behavior.

Ideal behavior is to declare objects as local variables on the stack, and pass them by reference if they are bigger than a pointer in size.
>>
>>59923275
ay you got me, with the array lengths having to be compile-time constants and such, very funny

that doesn't really have anything to do with what I said here though: >>59923238
>>
>>59923474
>Casting away const status AND THEN MODIFYING THE RESULT is undefined.
>No, actually it's undefined the rest of the time, too. It's not likely to cause a problem, but it's allowed to.

no it's not you fucking dumb fuck... look at me doing that exact thing here:

https://ideone.com/GKwLrp

it works bitch

ask about it on stack overflow, the language lawyers will prove you wrong.

in fact I just did that for you!

http://stackoverflow.com/a/4486393

>This code has undefined behavior if the object you actually passed a pointer to was declared const. The only time it's valid to write through a pointer from which const qualification was removed is if the originally pointed-to object was non-const. The same applies with other qualifiers like volatile

get told you fucking autist, by "R.." even, the biggest C language lawyer autist on that fucking site
>>
File: fdf.png (7KB, 417x257px) Image search: [Google]
fdf.png
7KB, 417x257px
>>59923275
what's supposed to happen?
>>
>>59916171
>>59916171
>>59916171
reuse
>>
>>59923605
it will not compile it with strict C89.

gcc probably has variable-length arrays enabled by default. its a horrible idea to use that feature since its essentially a memory allocation on the stack with no way to check for failure. it was made optional in newer versions of C.
>>
>>59923428
Nope. That's why there's explicit syntax for pointers and references in C++. Consider:
class MyObject {
public:
int my_ints[26];
};
MyObject o1; // especially long integer whose value equals the bytecode of an instance of MyObject
MyObject* o2; // pointer to a segment of memory CONTAINING the bytecode of an instance of MyObject
MyObject& o3 = o1; // pointer to the segment of memory containing the integer o1; also has the special property of automatically turning into what it points to whenever its name is encountered in your code, without your having to explicitly use the dereference operator
>>
>>59923553
>Ideal behavior is to declare objects as local variables on the stack, and pass them by reference if they are bigger than a pointer in size.
that makes sense
>>
>>59923635
Gcc defaults to gnu90 or gnu11 depending on your version.
>>
>>59923577
>it works bitch
"it works therefore it's not undefined behavior"
Nice argument

>http://stackoverflow.com/a/4486393
>"Your compiler will not stop you from doing this."
"the compiler allows it therefore it's not undefined behavior"
nice argument

>>This code has undefined behavior if the object you actually passed a pointer to was declared const. The only time it's valid to write through a pointer from which const qualification was removed is if the originally pointed-to object was non-const.
>get told you fucking autist
If you're the one writing a function, and that function is to be exported, and you declare a parameter as const, you have no guarantee the caller isn't passing in a value originally declared as const -- and if the caller DOES pass in a value originally declared as const, what your code is doing -- what YOUR code is doing, NOT their code -- is undefined behavior. It's your responsibility, as the author of your code, to proof it against undefined behavior.
>>
>>59923565
If the compiler can't even consider it a constant at compile time, how can you call it a real constant?
>>
>>59923780
For the following reasons:
* It's allowed to be allocated in read-only memory.
* The compiler protects you from accidentally assigning to it.
* The compiler doesn't protect you from assigning to it on purpose, using a cast, but doing so is explicitly allowed to make demons fly out of your nose.
>>
>>59923836
>Allowed
>You can though
>Should never allow it. Period.
>>
>>59923864
Safe error handling for all possible undefined behavior would be an enormous waste of time and memory. It's altogether a superior policy to only stop people who don't seem to know what they're doing, and let people who do seem to know what they're doing do it, even if it turns out they actually don't.
>>
>>59923920
All it has to do is have a conversion from const be not compilable. Since the very concept in undefined, I don't see why this is a problem and why you are fighting against it.
>>
>>59923962
>All it has to do is have a conversion from const be not compilable
Don't get me wrong, I wish they had done this. There's never a good use case for casting away const that's not better served by reconsidering your design.
>>
I'm making a program that manages text files with c++, do I need to worry about read/write permission for my program? It works fine on my computer but I don't want to to throw errors or just not work.
>>
>>59919426
It works if you correctly format it, which is
.iter()
.map(...)
.[...]
instead of a one-liner. You would also probably not put that inside the println!.
Thread posts: 361
Thread images: 18


[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.