[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 in Tcl

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: 314
Thread images: 21

File: tk.png (7KB, 354x520px) Image search: [Google]
tk.png
7KB, 354x520px
What are you working on, /g/?

Previous thread: >>61521295
>>
dumb muslim poster
>>
>>61526813
that's a feather, anon
>>
>>61526813
you mean dumb kiwi poster
>>
Really stupid question: if I've overloaded operator<, can I just do
bool operator>(const MyClass& other) {
return other < *this;
}


Specifically, will "*this" do what I expect it to? Is there anything I should watch out for?
>>
>>61526844
It will do what you expect it to.
>>
>>61526844
I should add, in C++
>>
>>61526844
why the fuck would you do that in the first place
>>
>>61526862
Not him but what happens if you do
bool operator<(const MyClass& other) {
return other > *this;
}
bool operator>(const MyClass& other) {
return other < *this;
}

Does the compiler hang?
>>
>>61526844
I assume you mean to write
bool operator>(const MyClass& other) {
return !(other < *this);
}

But this is misleading unless there's no way two of these objects can be equal, you should consider that case too.

>>61526892
It's infinite recursion and stack overflow. No difference to this.
void foo()
{
bar();
}

void bar()
{
foo();
}
>>
>>61526925
>I assume you mean to write
No he had it right.

(a > b) ==> (b < a)
>>
>>61524375
I agree with this completely but I generally don't make it this explicit for myself. I call things 'bad code' without any sensible reasons if I wrote it in a bad mood.
I'm sure there's instances where if I waited a year and looked at it again I'd be fine with it.
I find it difficult to see how a programmer could not feel this way about pieces of code you've written. Maybe all you feel is insecurity or hubris.
I'm a C/Python/C++ and asm programmer mostly.
>>
>>61526965
Oh shit, right.
>>
>>61526805
Just started learning C.
>The char *gets(char *s) function reads a line from stdin into the buffer pointed


What does stdin mean? I know it's a stream data, but this wasn't really clear to me.
Does it only mean it's what you type on keyboard?
>>
>>61526989
It's everything you type into the console when your program is running in it.
>>
Search for the /gd/ font share site
>>
>>61526844
>will *this do what I expect it to do
Isn't 'this' the lhs in the operator call in C++?

I'd never want to use something that arbitrarily reverts the ordering through overloading a comparison operator.

Maybe you should have expanded with a more silly example to get your point across (like adding a random number to each of the sides and then compare)? Sometimes more code can let people nail down what you were asking better.
>>
>>61526989
standard input, normally it's what what you type into the terminal but it can also be other data that's been piped in
>>
>>61527012
Thanks.
Another thing:

how do you read "*gets(char *s)"

Is it a funcion where you input a pointer?
>>
>>61527033
What difference is there between stdin and scanf?
>>
>>61527034

Yes. Doing *s will yield a char. Doing *gets(s) will yield a char.
>>
>>61527055
scanf is a function, you use it to read data in a certain format from stdin
>>
File: sc.jpg (22KB, 400x400px) Image search: [Google]
sc.jpg
22KB, 400x400px
>>61526973
tweeting any nonsense gets her likes
>>
>>61526989
It's what you type into the console or any input directed at your program through stdin.
Examples:
https://stackoverflow.com/questions/6541109/send-string-to-stdin
This also inputs to stdin.
Gets is a 'blocking call' meaning it will stay at that call until you send it input. That's why you get an opportunity to type in the information instead of the program just checking if there's something there and continuing on.
>>
>>61527032
>I'd never want to use something that arbitrarily reverts the ordering through overloading a comparison operator.
Why the fuck not? (a > b) ==> (b < a) in logic. Do you want that to not be true?
>>
>>61527032
Yeah "this" is the LHS, so if I have the '>' operator defined, and I want to define '<', I can do
RHS > LHS
. Other anons confirmed that my code should work.

I don't see what you mean by "arbitrarily reverting the ordering".
>>
>>61527124
>>61527143
mb. I misread.
>>
>>61527062
It's confusing me a bit, because I read it as pointer s, the size of char.
Is this it?

>>61527065
>>61527113
Cool, thanks.
>>
>>61527188
char *x;

You should read a declaration like this as "Dereferencing x will give me a char"
>>
anyone else amazed by how you can just type javascript code into browsers and it just works?
>>
>>61527209
Or more commonly put as "pointer to char".
>>61527221
Not really.
>>
>>61527221
python and lua both do that
>>
>>61527071
Don't see how that's all that relevant. Unless you're calling this nonsense, which I don't agree on.
>>
>>61527209
>>61527241

Ok, this makes much more sense.
I've always read it as "allocating memory space for a char"
>>
>>61527221
No I'm not all that amazed that there's interpreted languages.
I'm more impressed when programs hotload assets like dlls. That's neat.
>>
>>61527279
Don't confuse allocation with getting a pointer. You can get pointers to things which are already allocated.
char c;
char *ptr_to_c;
c = &c;
>>
>>61527279
Then perhaps it's worth to add that what you get after this declaration a pointer that doesn't point to a char you want it to point to (unless you initialized it). You'd have to allocate it or assign it a char to point to before you dereference.
>>
>>61527314
>>61527279

char c;
char *ptr_to_c;
ptr_to_c = &c;

Sorry.
>>
>>61527314
But in this case it shouldn't be ptr_to_c=&c ?
Gosh I'm so confused
>>
>>61526805
I want to be working in D but the apparent lack of debugging options in D blows huge D. No wonder this language isn't treated seriously.
>>
text based 3d engine.
>>
>>61527399
>but the apparent lack of debugging options in D
umotm8
https://wiki.dlang.org/Debuggers
>>
>>61527435
So essentially an ASCII renderer for 3D objects?
>>
>>61527399
why can't you use gdb or something liek it?
>>
I need a local database for an application I'm developing, but it must support multithreading (so no SQLite).

The DB must be local, or at least self contained (in the sense that if I distribute the application it will just werk).

I'm going to insert ~50k entries, so doing it in a single thread will take for ever.

What's the recommendation?
>>
>>61527467
a 3d engine is also an animator, lightning manager, collision calculator etc
>>
>>61527505
Of course, but I was asking about the "text" part.
>>
>>61526805
package require Tcl 8.6

proc gen {} {
yield [info coroutine]
for {set i 0} true {incr i} {
yield $i
}
}
proc replace {source factor result} {
yield [info coroutine]
while true {
set x [$source]
yield [expr {
[string is integer $x] && $x % $factor == 0 ? $result : $x
}]
}
}

coroutine numbers gen
numbers ;# drop zero
coroutine filter1 replace numbers 15 fizzbuzz
coroutine filter2 replace filter1 3 fizz
coroutine filter3 replace filter2 5 buzz

puts [join [lmap _ [lrepeat 100 whatever] filter3]]
>>
>>61527520
and my response was relevant to that. this renders 3d objects to ascii, lets you change the camera position on them, apply lightning, animate the objects etc
>>
>>61527564
Yes, so the renderer.
>>
What's the deal with the notation for declaring a pointer (let's say a pointer to an int) as seen in K&R?

int *ip;


It seems to make more sense if it were
int* ip
.
>>
>>61527591
cause
int *a, b
>>
>>61527591
"Declaration follows usage"

Doing * to ip results in an int.
In the same way:
int arr[5];
arr[2] // is an int
>>
>>61527498
>multithreading (so no SQLite).
you can still use it with a little extra work
>>
>>61527577
renderers dont animate or detect collision
>>61527591
the convention seems to be
int *ip

at least in OSS code. i'd stick to that if i was you
>>
>>61527591
int *ip; int * ip; int* ip;

Are all identical. It's just style. But the middle is objectively superior to the other two.

Likewise
const int
is identical to
int const
but the second is objectively superior, especially when you start throwing pointers into the mix.
>>
>>61527607
>>61527610
Cheers.
>>
>>61527625
>renderers dont animate or detect collision
Neither they have anything to do with the text part.
>>
in the SICP why does
(((double (double double)) inc) 5)

equal 5?
maybe i'm not cut out for scheme
>>
>>61527662
*equal 21
fug, my bad
can't even post right
>>
>>61527662
What is double defined as?
>>
>>61527650
Renderer will render fonts so the text is part of it.
>>
>>61527662
Also what's inc defined as?
>>
>>61527451
>Visual D
Garbage. I don't want anything to do with VS if I can avoid it.

>Mago
Similar to above. Still looks shitty.

>WinDbg
This kind of works. I can step through line by line but it isn't allowing me to see what variables exist and their values. Useless.

>ddbg
Looks like a dead project. Although there is a successor debugger called Ddbg which also looks to be near dead.

>OllyDbg 2
A debugger on an assembly level. Looks to suffer the same issues as WinDbg that I mentioned before though.

>>61527478
I'd love to use gdb. I'd shut my mouth if it would work but gdb doesn't appear to like any D compiled executable that I throw at it. I've tried to compile using DMD and LDC with different arguments and to no avail. I'm not writing some special program either. Just below:

import std.stdio;

int main(){

int num = 10;
int val = 20;

writeln("greetings globe");

return 0;
}


I'm really hoping that I'm just retarded and I'm not doing something correctly.
>>
>>61527662
daily reminder that lisp is the work of the (((chosen))) ones
>>
>>61527680
(define (double f)
(lambda (x) (f (f x))))

>>61527695
(define (inc x) (+ 1 x)) 
>>
>>61527702
We need a languages for [[[]]], {{{}}} and <<<>>>.
>>
>>61527696
>
import std.stdio;

int main(){

int num = 10;
int val = 20;

writeln("greetings globe");

return 0;
}

speaking of garbage.

void main()
{
import std.stdio: writeln;
int num = 10;
int val = 20;

"greetings".writeln
}

Why doesnt GDB work though?
Try VSC though, it has nice debugging stuff
>>
>>61527726
for the last one there's Rust
>>
>>61527726
>{{{}}} and <<<>>>.
sepples
>>
>>61527710
Do you know what (double double) evaluates to?

I think once you figure that out it will be pretty easy.
>>
>>61527730
>"greetings".writeln
absolutely disgusting
>>
>>61527770
Hello rustlet.
>>
>>61527726
>[[[]]]
matlab
>>
>>61527726
[[[]]] - see OP
{{{}}} - 2many2count
<<<>>> - C++
>>
If your language uses {}, [] or <> it's shit language.
Common lisp does not have this problem.
>>
>>61527702
young lisper reporting sir
>>
>>61527809
How do you find greater/less than?
>>
>>61527826
dumb shit poster
>>
>>61527820
when are you starting to work on the greater israel project?
>>
>>61527840
>ask a genuine on-topic question
>get called a shitposter
???
>>
>>61527852
>he knows
>shutitdown.lisp
>>
>>61527809
#include <stdio.h>

top kek
>>
File: 2017-07-23_21-31-51.png (13KB, 537x108px) Image search: [Google]
2017-07-23_21-31-51.png
13KB, 537x108px
Me again from last thread. Why do I get pic related warning, and how do I make it go away?
>>
>>61527826
(less-than a b)
dipshit.
>>
>>61527876
>breaks your parantheses key
its over shlomo
>>
>>61527881
you call me that gain, and you'll be in deep shit bro
>>
>>61527877
I said Common Lisp doesn't have this problem.
C is shit.
>>
>>61527757
ah, I see my error
for some reason I though it'd break down into 8 inc's. now I see why it'd become 16
>>
>>61527881
>have to type more because you refuse to have an operator
"""""""style""""""" over substance is awful.
>>
>>61527906
>my poor fingers
Just do
(define < less-than)
>>
>>61527906
> and < operators are different from
<> closing tags
.
dumb fuck.
>>
>>61527894
what if you need to compartmentalize the result of an expression, like for ex I can do in C
(1 || 2) && (2 || 3)

do you use pharanteses too or do you just commit suicide everytime you need to break up a statement into parts?
>>
>>61526805
trying to modify some ancient, spaghetti ridden embedded code, for a taxi intercom system
>>
>>61527943
In lisp that's

(and (or 1 2) (or 2 3))
>>
>>61527943
(and 
(or 1 2)
(or 2 3))

dumb blub poster
>>
>>61527933
>make a vague post
>get mad when people dont adhere to it
really says a lot desu
>>61527928
>have to alias an operator just to get sane functionality
awful
>>
>this is not allowed in C++

kek

vector<vector<char>> v;
>>
>>61527971
dumb shit poster
>>
>>61527981
How is it not
>>
File: fff.jpg (43KB, 236x252px) Image search: [Google]
fff.jpg
43KB, 236x252px
>>61527964
>Polish notation
>>
>>61527987
dumb dumb poster
>>
>>61527662
(double f) calls f twice.

((double double) f) doubles the act of doubling, calling f four times.

((double (double double)) f) calls (double double) nested twice on f, which we already know to call 4 times, so 4*4 = 16. 16+5=21

In other words, 2^2^2+5 = 21.

Also fuck lisp syntax. In Haskell this is just
(double $ double double) inc $ 5
>>
>>61527989
error: '>>' should be '> >' within a nested template argument list
>>
What difference is there between gets, scanf and fgets?
>>
>>61527989
ancient compilers would mistakenly tokenize the >> as a bit shift operator

none of the modern ones do and IIRC the standard changed to force that behavior
>>
>>61527981
> keywords not in the order of operations
lmao
your language is designed as good as ur face
>>
>>61528007
>In Haskell this is just
(double $ double double) inc $ 5

but that looks gay as fuck and unintuitive
>>
>>61528012
I'm pretty sure that got fixed in C++11

AKA 5 years ago
>>
>>61528049
>implying there's compiler that's fully c++11 compliant
>>
>>61528049
boost::array<int, 2048>>2> x;


what now
>>
File: 1500485573328.png (107KB, 523x364px) Image search: [Google]
1500485573328.png
107KB, 523x364px
>>61527928
(define > less-than)
>>
>>61528047
Not if you use it for a single week. It's used all over in Haskell, getting rid of a huge amount of nested parentheses in a predictable way that only affects the last parameter of your function call
>>
>>61528000
dummy
>>
>>61528072
#define < >

You can do this almost anywhere
>>
>>61528094
>
#define

Nobody is programming in sepples, dumb fuck.
>>
>>61528049
>Proud of a language almost as old as C, still getting basic-ass bugs fixed in 2011

Go to sleep, Bjarne.
>>
File: qxb9041pve9z.png (431KB, 1922x1428px) Image search: [Google]
qxb9041pve9z.png
431KB, 1922x1428px
>>61528094
>>
>>61528112
>sepples
you keep using this term
tell me anon, where did C++ touch you?
>>
>>61528007
>In Haskell this is just (double $ double double) inc $ 5
That's equally unreadable you fruit
>>
>>61528129
>touch
>implying pile of shit is able touch
dumb sepples poster
>>
File: fatcat.jpg (348KB, 1280x1707px) Image search: [Google]
fatcat.jpg
348KB, 1280x1707px
>>61527880
guys pls
>>
>>61528007
Whats the tersest haskell for that?
(pow(2,4) + 5).writeln;
>>
File: 1483836935788.jpg (34KB, 489x479px) Image search: [Google]
1483836935788.jpg
34KB, 489x479px
>>61528116
Post sourcecode
>>
>>61528116
how the fuck tho
>>
>>61528153
anon, were not gonna make progress like this
>>
>>61528112
That's C you numbnut

>he's so buttblasted about C++ he sees it in literally everything that looks remotely like it
>>
>>61528142
See >>61528077

>>61528160
print $ 2^4+5
>>
File: 1495258316510.png (17KB, 283x266px) Image search: [Google]
1495258316510.png
17KB, 283x266px
>>61528116
>1488 words
>finished faster
>>
>>61528155
how bout you google your error, anon?
>>
>>61528178
>implying you can't
#define 
in sepples
>>
>>61528007
>fuck lisp syntax
t. doesn't use macros

>>61527998
It's not polish notation because procedure application is variadic. Polish notation doesn't have variadic operators so it would just be

and or 1 2 or 2 3

You also give up the ability to pass functions without some disgusting reader macro. Although common inferior lisp already has done that.
>>
>>61528077
>>61528182
That doesn't make it any less obtuse though, you're still calling double 3 times only now you have $ mashed in there.

If anything the lisp solution is cleaner, and you can even just use line breaks (like you should) if parenthetical nesting upsets you.
>>
>>61527730
>speaking of garbage.
Doesn't matter. Both my code or your "clean code" doesn't debug in gdb.

>Why doesnt GDB work though?
Beside the comment it spits out below, I really don't know why.
>"helloworld.exe": not in executable format: File format not recognized

Which is weird because it executes just fine when called upon. The only arguments I pass to dmd is -g and -debug when I compile. Not sure what I'm missing or if I'm just retarded.
>>
>>61528207
>implying you
#define
in sepples nearly as much as you do in C
>>
File: IC799897.jpeg.png (8KB, 629x194px) Image search: [Google]
IC799897.jpeg.png
8KB, 629x194px
I started learning programming last year in uni, just first year so it was only a few languages. We used IDEs like VS for all of them. I know Vim is hot shit and would accelerate my journey to alpha dork so I'd like to start learning it. My reservation is that I am used to the IDE compiling the code and spitting out errors for me to rectify. I know Vim is just a text editor so my question is, is there any way to set it up so it has this kind of functionality (for those of you who have used VS pic related is what im talking about)?
>>
>>61527880
because your class does:
int idx; string name_string;


instead of the order you're using in the constructor
>>
>>61528222
>you can even just use line breaks (like you should) if parenthetical nesting upsets you.
explain
>>
>>61528239
Visual Studio Code.
Its the best of both worlds, desu.
>>
File: DClRY3uVYAApz0m.jpg large.jpg (144KB, 1405x951px) Image search: [Google]
DClRY3uVYAApz0m.jpg large.jpg
144KB, 1405x951px
>entire algorithm to generate Google Authenticator codes.
>>
>>61528248
Lisp isn't whitespace sensitive.
>>
>>61528234
>using "limited subset of sepples"
if you don't use
#define
for everything you are not real C++ programmer.
>>
>>61528262
I know that, but how does that change nested parentheses
>>
>>61528239
There are several ways to integrate that functionality in various different styles.
This is just one
https://github.com/vim-syntastic/syntastic
>>
>>61528239
YouCompleteMe

Vim may be hot shit but it's also dog shit for some languages, like Java. But for C, C++, C#, or even Javascript, it's pretty great.
>>
>>61528268
nibba, what the fuck are you on
>>
>>61528268
Too much like C. A true sepples programmer strives to write as little C as possible.
>>
>>61528291
>nibba

gb2 rdt
>>
>>61528273
(((double 
(double double)
inc)
5)

Each parenthetical stop gets its own line because it's its own "statement", which if looking at ))))) all day hurts your tiny brain makes Lisp much more readable.
>>
>>61528284
>syntastic
Ooh nice, never saw this before for some reason. Can anybody who's used both YCM and this give a comparison? For C/C++ development.
>>
>>61528287
Vim was mad annoying when trying to write Linux drivers though.
>>
>>61528220
I didn't say it was pure polish notation.

Anyway, using prefix-type notation in anything other than ASM is insanity.
As you said yourself, you already have variadic operators available so what benefit can there possibly be of putting the operator first?
>>
>>61528239
> I know Vim is hot shit and would accelerate my journey to alpha dork so I'd like to start learning it.
dont. use it when you have to. learn it along the way.

> is there any way to set it up so it has this kind of functionality
that happens when you run your code.

>>61528116
this is the kind of content i browse this board for.
>>
>>61528220
Macros don't change lisp syntax. They just allow for compile time metaprogramming, which Haskell has as well (but it's much less needed)

>>61528222
No, it's immediately obvious what's being called on what without having to mentally match parentheses, because Haskell uses operator precedence to determine that in a human way rather than force the programmer to drop a clusterfuck of parentheses.

In Haskell, function calls have the highest level of precedence and operators are guaranteed to separate functions calling other functions.

This means that, using $, which is an operator that effectively indicates the last argument of a function call, you know, without having to match lots of parentheses, that the argument list of a function call ends there and you're seeing the last parameter. It's really common that programs follow this syntactical structure, meaning you can read a chain of function calls without having to look back at where the parentheses match simply by following the operators.
>>
>>61528239
The best way to get that is to multiplex your terminal and have one pane with your compiler.

Learn how to use makefiles.
>>
>>61528305
thats not valid, you missed a parentheses
 (((double 
(double double)
)
inc)
5)


there's plenty of instances where you're either going to have more than one ), or you're gonna have a bunch of lines with nothing but a single )
>>
>>61528350
>It's easier to read because you don't have to look at brackets!
>Look! You just have to understand operator precedence with no syntaxical sugar and you just need to know how this special character affects the order of execution and know that haskell is the best because I say so
Again, if matching brackets hurts your tiny brain so much just use a couple newlines.
>>
>>61528323
>>As you said yourself, you already have variadic operators available so what benefit can there possibly be of putting the operator first?
>(1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9)
>vs
>(+ 1 2 3 4 5 6 7 8 9)
>>
Behold the glorious implied DO loop of Fortran

! Implied DO loop example
PROGRAM impl_do
IMPLICIT NONE

INTEGER, PARAMETER :: num = 3
INTEGER, DIMENSION (1:num, 1:num) :: matrix
INTEGER :: row, col

PRINT *, 'Enter elements for a matrix of integers'

DO row = 1, num
PRINT *, 'Enter elements for row #', row
READ *, (matrix(row, col), col = 1, num)
END DO

PRINT *, 'Your matrix is:'
DO row = 1, num
PRINT *, (matrix(row, col), col = 1, num)
END DO

END PROGRAM impl_do
>>
>>61528387
Which you clearly already fucked up in >>61528305. Very reassuring.
>>
>this kike still trying to shill lisp
>>
Guys, in A Tour of C++ Bjarne told me to use braces {} in initialiser lists:
My_Class {
public:
My_Class(int val) : myVal{val} {
//body of constructor
}
private:
int myVal;
}


But I keep seeing literally everyone on the internet use brackets () for it:
MyClass {
MyClass(int val) : myVal(val) {
//...

What gives? Are both syntaxes equivalent? Are there differences?
>>
>>61527505
this is actually very interesting
>>
>>61528323
Uniform syntax makes syntax transformation easy.

>>61528350
Depends what you consider syntax is.

I'm guessing you think let and if aren't syntax then since they're just macros to nested lambdas and cond?

>compile time metaprogramming
What the fuck does this mean? A macro is just a syntax transformation, and if you're using (syntax-rules), then it's just syntax pattern matching.

Also this is 2017, computers have multiple color displays, so use a fucking rainbow parenthesis plugin like a sane person.
>>
>>61528438
Bjarne didn't think having only one gun with which to shoot yourself is dangerous enough, so he tied 7 guns together and rigged each trigger to fire all 7 simultaneously.

However, the guns will fire slightly out of sequence, in a different order every time, and are tied together in such a way that it's impossible to hold it without at least one barrel pointing at your face.
>>
>>61528438
I didn't know they were equivalent if they are... I always use () because that's what I've seen being used. If anything {} is a secondary option that happens to be equivalent. It's also useful for initializing vectors or fields of data types

struct my_pod {
int x, y;
};

class MyObj {
public:
std::vector<int> nums;
my_pod p;
int z;

MyObj();
};

MyObj::MyObj()
: nums { 1, 2, 3, 4}
, p { 3, 4 }
, z(3)
{}


>>61528485
Funny and also accurate...
>>
>>61528438
Using () can fail in certain peculiar ways, while {} pretty much always does what you expect. The figureheads of the language would tell you to get into the habit of only using {} unless you specifically need () for one reason or another so that you avoid those weird limitations.
Initializing everything with {} was only introduced with C++11 though, so most people are familiar with using ().
>>
>>61527894
Don't say that. C is the cutest little thing :3 Also fucking powerful
>>
>>61528007
You actually don't need $ at all.

double (double . double) inc 5

is fine.
>>
>>61528513
Ah, thanks. So I can just basically ignore the () syntax in this case, right? (Assuming I don't have to deal with pre-c++11 code)
>>
>>61528513
>Initializing everything with {} was only introduced with C++11 though, so most people are familiar with using ().
How did this happen, everything else uses {} for initializing and they just decided to use () for no reason initially? Then did it anyway. C++ please.
>>
File: 1500833571338.jpg (1MB, 2414x1715px) Image search: [Google]
1500833571338.jpg
1MB, 2414x1715px
I C# because i live in a visual studio
>>
>>61528541
Yeah. According to a modern style guide, you should default to using {}.
The only time I can think of where you might want to use () is with vectors.
vector<int> a(5); // declares a vector with storage for five ints
vector<int> b{5}; // declares a vector containing just one int, which is 5
vector<int> c{5, 6}; // declares a vector containing 5 and 6.


>>61528565
When C++ began they just use () for initialization with constructors, then they found out that it was often confused by the parser for function declarations so they began using the unambiguous {}.
>>
>>61528473
>I'm guessing you think let and if aren't syntax then since they're just macros to nested lambdas and cond?
That's supposed to be the beauty of lisp, isn't it? That it's not syntax because the program is isomorphic to its own datastructure?
>What the fuck does this mean?
You can call it what you want. It still has to fit into lisp's AST.
>so use a fucking rainbow parenthesis plugin
I'm not precluding using tools to help you deal with how shitty lisp syntax is on its own. But instead you're searching for one in a haystack of identical symbols that is a particular color, which is still ridiculous compared to actually having visible program structure that indicates it instead. If you're lucky you'll have THREE shapes to choose from, (, [, and {, - wow!
>>
>>61528433
>implying I'm jewish
>implying me asking questions is shilling
ISHYGDDT
>>
>>61528566
I'd tell you a UDP joke but I'm not sure you'd get it.
>>
>>61528606
What a clusterfuck. I'm sticking with () personally.
>>
>>61528566
good for you anon
>>
>>61528627
well we have one official noseman here, so i can assume more roaches will follow.
>>
>>61528639
wait, you're telling me there's an actual jew shill here, and he's open about it?
he didn't go all "i've been found out" and flee?
>>
Why all the rust hate? It's basically c with a modern type system and package manager.
>typing this comment while my code compiles
>>
>>61528669
he got into an argument about recursion being more natural than iteration and then told us he makes him homeschooled children do math in scheme.
>>
>>61528631
Yep, I agree.
C++ constantly suffers from its legacy and backwards compatibility requirements, and this time it's suffering because of C's include/function prototype system.
D could have been so comfy if it didn't shit the bed with GC, it does (almost) everything else right.
>>
I want to make a simple telegram bot (possibly in python but if that adds complexity I can adapt to other langs) that sends users some sentences and pics at given times of day, and as a plus I also wanted it to send images from a subreddit (mostly to tweak with the reddit APIs a bit, not really interested in that feature anyway), and I would like to do it simply via a github.io domain or something like that if possible, I don't want to use google cloud service or other bloatware like that. Can you help me by pointing me at some useful resource to achieve this?
>>
>>61528687
>he got into an argument about recursion being more natural than iteration
kek
>and then told us he makes him homeschooled children do math in scheme.
what was his logic in doing this?
>>
>>61528685
>It's basically c
L
O
L

also
>acting like anyone was talking about rust till you brought it up
fuck off shill
>>
>>61528610
It's syntax because you DEFINE SYNTAX retard.

(define-syntax let
(syntax-rules ()
((_ ((var val)...) body ...) ((lambda (var ...) body ...) val ...))))
>>
>>61528710
I forget, he was just your diamond dozen lisp cultist though.
>>
>>61528606
Wait, are constructor initialiser lists the same as variable initialisation on declaration?

As in when you do
int var = 5;
//alternatively
int var {5};

That's the exact same thing as when you do
MyClass {
//constructor
MyClass (int val) : var{val} { //body }
}

?
Does that mean you can also do
MyClass (int val) : var=val { //body }

?

That would clear up quite a few things, because I thought those constructor lists were a special case.
>>
>>61528692
Let's put our differences aside and consider Rust for a moment. As it has the benefit of hindsight, it does a lot of things right. Less implicit behavior, more runtime checks, actual module system, and generics that are easier to reason about. However it is going down the path of "add every feature in sight"... they just made it so that break can return values?
There's this feeling that infects people who work in complicated languages, that having a full grasp of the language is such an impossible task that you shouldn't strive to achieve it, you should just work in whatever subset you do understand, and people who know the entire language are regarded in awe. This is a fucking terrible phenomenom and it leads to horribly bloated languages that just keep expanding. How the fuck do we escape this?

>>61528779
> MyClass (int val) : var=val { //body }
No, this isn't a thing.

Basically, in C++,
Typename  var ( init_value );

This is the standard way to declare variables.
Typename var = init_value;

This is optimized into the above automatically, but it is actually secondary syntax.

If you know C, here is something that helps me understand C++ better: C++ is NOT a superset of C. C++ is a much more complex language, which syntax and semantics that look so much like C that they succeed in tricking you into thinking you're writing C when in fact you're writing C++. Different things go on in the background but the end result *usually* does the same as C. Here's an example, valid in C++ but not in C:
int x = 3, y = 4;
int* p = &(x < y ? x : y);
>>
>>61528779
>Wait, are constructor initialiser lists the same as variable initialisation on declaration?
Yeah, I think that's more or less the idea.
>Does that mean you can also do
MyClass (int val) : var=val { //body }

Didn't work for me. I have to say, I have no idea how initialization works with = outside of constructor initializer lists either.
>>
>>61528732
You're not actually escaping the clusterfuck of parentheses though. It might be CALLED define-syntax but that doesn't change the fact that lisp macros simply make transformations to the AST of the program.

Everything you write is still constrained by a primitive formal grammar that gives almost no visual or grammatical expressivity.

You can call that "beautiful", and in one sense it is, but it's not more suitable for use by humans compared to a syntactical system which which doesn't restrict itself that way and makes utility a priority.
>>
>>61528832
>Here's an example, valid in C++ but not in C:
But why? That makes perfect sense to me. I don't get it.
>>
>>61528832
>Basically, in C++,
I mostly get that, I'm just confused about the lists of initialisations during constructor declarations specifically.

And I have a basic understanding of C (I read like half of K&R once), but after like three days of writing C++ I probably know more C++ than C at this point.
Unfortunately I did have to do a year of java which makes some things pretty annoying to think about, but I think I'm doing pretty well.
>>
>"“There are only two kinds of languages: the ones people complain about and the ones nobody uses.” ― Bjarne Stroustrup
>>
>>61528709
Bump
>>
>>61528925
https://core.telegram.org/bots
https://core.telegram.org/bots/samples

good luck
>>
>>61528915
"Look at me and my redundant proclamation i think is profound"
>>
>>61528832
Unless minimialism is one of the stated goals, feature bloat is inevitable. I don't really think there's more to it than that.
>>
>>61528946
made you reply
>>
>>61528779
They are a special case, when the members of a class support list initialization. A simple example is a class with a vector member:

#include <vector>
#include <cstdio>

struct S1 {
S1(int x) : a(x) {}
std::vector<int> a;
};

struct S2 {
S2(int x) : b{x} {}
std::vector<int> b;
};

int main()
{
S1 s1{2};
S2 s2{3};
printf("%lu\n", s1.a.size()); // "2"
printf("%lu\n", s2.b.size()); // "1"
return 0;
}


A complete explanation is here: http://en.cppreference.com/w/cpp/language/initializer_list
>>
>>61528851
Yall both missing the real point of Lisp. The point of Lisp is the to use s-expressions as a primitive building block to easily create small languages. Programming is about taking abstract specifications and turning them into unambiguous code. Languages are ways to bridge that gap, by allowing you to write the details of your specification in a way that is most natural to the problem domain. The macro system lets you transform those specifications into code.

>>61528873
In C++, when you refer to a variable, e.g.
int x = 3;
x // <- here

The type of that individual expression is not "int". It is "int&", meaning its a reference to x. When you do something such as
void foo (int);
foo(x)

You give foo an int&, but it expects and int, so it implicitly dereferences the int& into int, giving the actual value of x.
When you put a & before an expression, it takes a reference (T&) and turns it into a pointer (T*).

Therefore, the compound expression (x < y ? x : y) has type "int&". We put a & before it, so we get an int* and it works as expected.

In C, there is no reference type (e.g. int&). There are just pointers and integers. Therefore the expressions x and y both get immediately evaluated into their values (which has type int), and you can't make a pointer out of that.
>>
>>61528980
I'm the Haskell guy - what have I said that contradicted that?
>>
>>61528980
In C it's an rvalue int, and in C++ it's an rvalue reference to an lvalue int (aka an int&)
Am I reading this right?
>>
>>61529012
>Everything you write is still constrained by a primitive formal grammar that gives almost no visual or grammatical expressivity.
I guess my point is that you as the programmer are responsible for creating grammatical expressitivity.

Also maybe you just need to write more lisp so that it becomes more readable to you.

>>61529054
That might be right but I think they keep changing the internal semantics in C++, something like "plvalues" and "xvalues". What the fuck is the C++ commitee doing?
>>
>>61528977
Oh ok, thanks. I'll read up on it later, but is my basic understanding so far correct?

>you can initialise variables with {}
>some variables can be initialised with () and behave differently in this case (e.g. vectors, as in your example)
>you can also use '=' as a legacy compatibility syntax
>constructor initialiser lists behave exactly the same, except they don't accept the legacy '='

Is this more or less right?
>>
>>61529089
Oh yeah also

>normal variables (i.e. ones not covered by the second bullet point) can also be initialised with () which is then equivalent to {}
>>
>>61529089
>>some variables can be initialised with () and behave differently in this case (e.g. vectors, as in your example)
Most variables can be initialized with (). Of those which can be initialized with (), most of them initialize the same as with {}, and a few initialize differently.
>>
>>61529089
Yep. Also = is actually useful because of the 'auto' keyword that does type deduction. You will get to this eventually.
auto var = get_some_complicated_type();

auto is used extensively in real C++ code
>>
>>61529136
I've already used auto, yeah.
I take it () and {} can only be used for literals then?
>>
>>61528851
You think C++ has expressive grammar because it has lots weird reserved symbols? It's the opposite. Lisp's syntax was designed to be building blocks, and macros are tools to abstract away the building blocks.

And yes, macros do escape parenthesis clusterfuckery.

Compare:
(let* ((a 1) (b (+ a 1))) (+ a b))

to
((lambda (a) ((lambda (b) (+ a b)) (+ a 1))) 1)


The language with let* is definitely different from the language without it. A let* macro allows a lisp-with-let let* program to be run on a lisp-without-let* machine.

Macros define mappings between ASTs. To say that before and after are the same thing is retarded.

If you want to understand lisp, realize that it isn't a list processing language, but a tree processing language, and that the entire source code of a lisp program is a tree.
>>
>>61528945
Why do i have to use those 3rd party tools? Shouldn't API be meant to be used directly? Or are telegram's devs so pajeet that they don't even consider it?
>>
File: bait-but-nevertheless-correct.png (17KB, 522x384px) Image search: [Google]
bait-but-nevertheless-correct.png
17KB, 522x384px
>>
>>61526805
*tcls cute trap feet*
:3
>>
>>61529214
Nothing stops the languages in "fast development" from being faster than C.
>>
>>61529421
Then why aren't they faster than C?
>>
>>61529083
And that's my argument - that you can still accomplish this while putting some of the weight on the language, and that's what a language's responsibility is.

>>61529168
>You think C++ has expressive grammar because it has lots weird reserved symbols?
Quantity has nothing to do with it. I made a specific case for why Haskell's operators are useful regarding precedence and function call patterns.
>And yes, macros do escape parenthesis clusterfuckery.
And sure, you can get less nested parentheses with macros - obviously that's the point. But even in that trivial example you go four levels deep. At some level you can't escape the fact that you have to pass parameters to the macros through lisp's AST and the programmer has to use this. In Haskell that's
let a=1; b=a+1 in a+b
. Are you seeing the pattern?

Also, using lambdas, for good measure:
(\a -> (\b -> a+b) $ a+1) $ 1
>>
>>61529445
They aren't faster than C and C isn't faster than them for the simple reason that both C and these languages are just languages, not their implementations.
>>
>>61528851
Most C programs are valid sexpr. With a good enough macro you can execute C programs.
>>
>>61529461
>\symbol for lambda
Absolutely Disgusting
>>
>>61529480
Then why are you even bothering with lisp if the programmer's responsibility upon loading up the runtime is to make their own nonstandard computing utility platform with completely different syntax?

>>61529527
(you)
>>
>>61529527
(\\2(\\\2(321))1)(\1)(\1)
>>
>>61529561
>if the programmer's responsibility upon loading up the runtime is to make their own nonstandard computing utility platform with completely different syntax?
It isn't, it just shows that in Lisps you are free to implement most languages on top of sexprs. Something that you can't do in haskell for example.

>(you)
Is this your only argument?
1: \ has nothing to do with λ, some braindead retards just thought that it looked similar
2: sane people use \ for escaping characters
>>
>>61529461
>through lisp's AST
No, through >your< AST.

Your haskell code goes 4 layers deep too, but you just can't handle parentheses.

let a=1; b=a+1 in a+b

and
(let* ((a 1) (b (+ a 1))) (+ a b))


have identical ASTs. Specifically, the haskell's AST is the lisp code.

I'm seeing the pattern that haskell's syntax is far more irregular and more difficult to play with.
>>
>>61529371
>>61526805
error [string reverse [string map [list a o o a f i i f c \ ] goicocsfcpa]]
>>
>>61529561
> is to make their own nonstandard computing utility platform with completely different syntax?
Because no single syntax is capable of accurately expressing every problem domain, so we use Lisp to allow us to better express the problem by changing the syntax
>>
>>61529659
w-what does this do?
>>
>>61529617
I don't know how many times I have to reiterate this. https://wiki.haskell.org/Template_Haskell Haskell has the exact same kind of facilities, it's just a more useful language so we can usually use our own standard instead of making new constructs that every new programmer will be confused by when they read the software.

>>61529617
It's a retarded argument, but I'll give you just one (You).
1. It's close enough, lambdas are used frequently enough that they deserve a quick symbol
2. That's only relevant in the context of a string

>>61529632
>Your haskell code goes 4 layers deep too
That's my point - Haskell makes it far easier syntactically to do the same thing.
>but you just can't handle parentheses
Is that how really the world works in your head?

>>61529663
So that's Lisp's answer? Instead of building a standard whose objective is to reasonably cover as many problem domains as possible before forcing programmers to create nonstandard solutions, it's to give up and force nonstandard solutions for everything non trivial on every programmer?
>>
>>61529214
there's a common lisp implementation that claims faster-than-C performance
>>
>>61529750
>https://wiki.haskell.org/Template_Haskell
Less powerful and more complex.

>it's just a more useful language
lol

>1. It's close enough
You must have a serious mental disability to think that.

>2. That's only relevant in the context of a string
No, you might want to have a symbol that contains characters that need to be escaped.

>Instead of building a standard whose objective is to reasonably cover as many problem domains as possible
Something that haskell does not do.

Why would anyone like haskell? It is literally the worst of every world. If it only had a proper type system it would be fine but it does not.
>>
File: IMG_0763.jpg (192KB, 640x508px) Image search: [Google]
IMG_0763.jpg
192KB, 640x508px
>>61526805
How hard is the step down to webdev? I want to make some money on the side, was thinking of maybe getting into webdev for that advert money. How difficult would it be to make a streaming site or something?
>>
What's a good resource for learning Haskell if I already know a few languages?
>>
Added search, foundries and basic tags
>>
>>61529750
>nonstandard solutions
You just don't get it. Macros turn things which would otherwise require a noncompliant compiler into something which IS standard because it's just a library.
>>
>>61529875
>>>/wdg/
>>
>>61529841
Back-End stuff is ok, at least for me, but frontend development is a fucking mess. Shit breaks because of retarded reasons and it's an established fact that frontend developers can't code.
>>
>>61529750
Lisps syntax allows you to express anything you ever need.
What makes lisp great is the ability to create new syntax for specific things you do often.
>>
So /g/ I wanted to ask you guys if there are sites on the internet where I can get "minijobs" as a programmer to earn a few bucks on the weekend with small projects. I have a job but I thought earning a few bucks doing some smaller coding stuff could be great. are there any places where you can do small stuff that only takes a few hours and get paid for it ?

I mainly would like to do stuff in Python, Java and/or Web Developement.
>>
>>61529899
>>>/mlp/
>>>/cm/
>>
>>61529841
>step down
>How difficult would it be to make a streaming site
There's no stepping down for you, nigger.
>>
I used LYAH and the Haskell wikibooks site. Also the Haskell wiki quite a bit. Those resources go, from left to right, increasingly more assumptive that you're already knowledgeable about programming.

>>61529818
>Less powerful and more complex.
Equally powerful and type safe, actually. The rest of your reply is just trolling so I won't bother.

>>61529880
That's not my point. It's great that you can do these things at all in lisp (congratulations!). My point is that for a large fraction of these macros you're creating Haskell already has solutions in its standard library. For the majority remaining Haskell is expressive enough to represent efficiently without macros, and for those small set of cases remaining there exists template Haskell, which is well supported and does the exact same thing except it's type safe.
>>
>>61529750
>So that's Lisp's answer? Instead of building a standard whose objective is to reasonably cover as many problem domains as possible before forcing programmers to create nonstandard solutions, it's to give up and force nonstandard solutions for everything non trivial on every programmer?
There is a version of lisp where you can apply parameters to a procedure in an arbitrary order, and where parameters are optional. You can turn that ugly:
(foo '() #f '() bar 0 2 0)

into
(foo depth: 2 thunk: bar)


Interested in running it? Don't worry anon you don't need download a new compiler to run it.

Just download the library on:
https://srfi.schemers.org/srfi-89/srfi-89.html
>>
C++ related question.

I have something like this:
uint8_t *sample = &example[offset];
if (depth != 16) {
for (; sample < end; sample += bytes) {
if (*sample != x) {
test = true;
break;
}
}
}
else {
for (; sample < end; sample += bytes) {
if (*reinterpret_cast<uint16_t*>(sample) != x) {
test = true;
break;
}
}
}

but I'd like it to use the same loop without branching, and without an abstraction that just masks additional superfluous checks. At present it's just ugly.

Tried some stuff with initially conditionally casting a void*, still trying to figure that out. Or starting with a uint8_t* and casting to uint16_t. Doesn't really make sense, but I don't know x86 ISA very well.
>>
>>61530002
>Equally powerful
Not really

> The rest of your reply is just trolling
Yeah, everything you disagree with is trolling.
>>
>>61530002
Er, the first part of this reply was meant to point to >>61529868
>>
>>61530004
Okay, that's a cool macro. What's your point, though?

>>61530023
Alright, I'll give you the benefit of a doubt, anon.
>If it only had a proper type system it would be fine but it does not.
Name one of the problems with Haskell's type system and then we'll try to have a discussion about it.
>>
>>61529841
>How difficult would it be to make a streaming site or something?
If you have to ask, it's too difficult for you
It's more about infrastructure than application
>>
What is the best language for learning memory management and how it works?

C? Go? Rust? Something else?
>>
>>61530215
What do you mean memory manage? Assembly would probably be the best.
>>
Daily reminder that the impact of a speed decrease from 2 pass compilation is dwarfed by the decrease in complexity with regard to managing headers, forward declaration, figuring out how to write what you want to write without producing a circular dependency and ultimately breaking down and writing the goddamn forward declaration you didn't want to have to maintain with every tiny little change that might happen to the function's parameter, or variable.

I have classes where I just left everything public because I didn't want to alternate between public and private.

But really, headers. What a pain in the ass.
>>
>>61530215
C. Those other languages manage it for you

>>61530227
Assembly makes you focus a lot on the assembly and not the memory management though. You would have to learn to call glibc just to get started, and then you're doing the same thing as C just with assembly. And if you avoid using glibc, then it's even more work.
>>
>>61530275
>>61530215

>Those other languages manage it for you

the kernel manages it for you, C is not a "low level language" and you will not learn how memory works by using C
>>
>>61530271
That's what Go was designed to change tho, and the reason why Go is one of the fastest, if not the fastest, language to compile.
>>
>>61530215
C
>>
>>61530096
My point is that it's standard because you can just download it. You can use that syntax in Guile, MIT, Bigloo, Chicken, Chez, Chibi, some random guy's toy 500 LOC scheme interpreter, etc.

Saying that Scheme is shit because what you get out of the box is minimal is retarded. No shit what you get out of the box is minimal. The Scheme specification is 50 pages long.

http://www.schemers.org/Documents/Standards/R5RS/

Meanwhile, Template haskell is limited to GHC and maybe other compilers copying it.

>>61530215
Assembly, but out of your list, C.
>>
>>61530291
>the kernel manages it for you
No it doesn't. The allocation lives in the C standard library.
>>
>>61529682
https://ideone.com/v0Ufpb
>>
>>61530309

yes it does you tard, "alloc" doesn't mean shit until paging is set up
>>
>>61530322
The kernel provides sbrk or whatever, but that alone is not an allocator.
>>
>>61530309
Please show me your implementation of malloc that doesn't use a syscall or any functions that use syscalls.
>>
>>61530346
See >>61530343
>>
>>61530346
void *
malloc (size_t n)
{
return 0;
}
>>
>>61530362
Anon asked how to learn how memory management works. Using malloc isn't going to teach him how it works because malloc makes it magic.
>>
>>61530215
C, if anything, but really you want to learn about how memory and a processor actually work. You don't even need to learn any assembly, just looking into the basics of how information is exchanged between main memory and the cpu, prefetching, cache lines, and the cache itself. Then learn a bit about registers and basic stack / memory addressing.

It's really more about mechanical logic and understanding that there is no magic and humans are in no meaningful way the creators, everything requires a means and those means are dependent on the underlying rules of the universe. When you eg create and access an array, that has to happen somehow. Just like when you create shelves in your house, you need a way to store a mapping of their contents to arbitrarily access a given item, which is further dependent on if you can go right to it or if there's shit in the way. You see the same constraints arise in data structures. if you're walking around in a circle, or to a certain location, you need a means to recognize where you started / intend to end. Either you have to store a landmark and keep checking against that data, store a distance and increment a counter in mind, or identify when you've gone too far via non-valid data. You see the same constraints at work in computers with null terminated strings, vectors storing their size, bitstream parsers trying to recover or read over malformed / corrupted data. Etc.

It's all the same. All you need to realize is how similar, and simple, everything really is. As above, so below.
>>
>>61530413
If you're going to learn all that shit that you just mentioned, it would be such a waste to not learn assembly too, because if you knew all that shit, all you'd have to do is learn the names of some opcodes.
>>
>>61530291
If he's at the stage of asking which language to use to learn about memory management though, do you really mean to tell him to dive straight down into linux syscalls and ask him to learn sbrk or mmap? You want to ask him to implement a linked list containing arbitrary data sizes in assembly just to get a feel for how memory allocation works? That's a big ask.

>>61530301
>My point is that it's standard because you can just download it.
Alright, that's fair. This is a hard point for me to discuss since I don't know the Lisp library landscape very well. But I can't imagine having dozens of separate 3rd party solutions for the same things that come with the Haskell standard library being a superior alternative. Especially when they have to interoperate with each other.
>Saying that Scheme is shit because what you get out of the box is minimal is retarded.
Yeah, I'm not really complaining about Scheme, I know what it's for.
>Meanwhile, Template haskell is limited to GHC and maybe other compilers copying it.
GHC is kind of *the* compiler for Haskell though. Nobody can approach it in versatility and performance. It supports many backends and types of code generation. There are
alternative compilers like Haste that reuse GHC's frontend/type checking but introduce completely different code generation.
>>
>>61530435
It'd be faster and more readily accessible to just learn it that way. Though in doing that you'll probably almost necessarily run into at least some sort of assembly.

Doesn't anyone have a link to that pdf about how memory works (on a hardware level), cpu caches, etc? I recall it was related in some way to bsd, or that was where it was hosted, or something.
>>
>>61530215
If you're looking for modern memory management stuff then write your own allocators in C++ or Rust. I'd choose C++ but that's more that I'm familiar with it than that it is a good choice here. Even C would be mostly fine but it is harder to automate behaviors in C since you don't have destructors.
Or if you just want to get familiar with languages without GC then C or C++ are both reasonable choices. C++ does automatic object destruction (execute arbitrary code when an object leaves scope or is `delete`d) which allow you to construct "smart pointers" and other stuff to dig deeper into memory management techniques while still requiring to write most of it yourself.
>>
Could one make a Haskell/Idris but with Scheme/Lisp-like syntax?
>>
File: 4sgqcNW.jpg (148KB, 392x495px) Image search: [Google]
4sgqcNW.jpg
148KB, 392x495px
>design a SQL database in SQL Server Management Studio
>created a windows forms application in VS2015
>generated classes for all tables in the database by ADO.NET wizard so I can access database records like regular objects
>also created a DataSet of that database to use it in DataGridViews in forms
>DataGridViews automatically imports columns and rows of their corresponding table
>you can rename, rearrange columns, change cell design(like, make it a combobox with items from other table) and much more
>DataGridViews automatically INSERT, UPDATE and DELETE records in the database
Comfy as fuck. I can only imagine how many lines of code I would have to write in your meme languages to accomplish what I did with ZERO lines of code. C# is love, C# is life.
>>
>>61530017
Reposting.
>>
File: 4chantheshitpostingguide.png (147KB, 500x700px) Image search: [Google]
4chantheshitpostingguide.png
147KB, 500x700px
Learning the command line and shell scripting so I can start doing microorganism simulations in C++.
Eventually I want to build up to increasingly complex organisms, or somehow develop simulated evolution.
Dis gon be gud
>>
>>61530818
>Idris with just (, )
Id rather kill myself and be sent to rust code monkey hell
>>
>>61530818
Yes, it would just be a statically typed lisp with automatic currying.

It would suck
(((fold +) 0) [1 2 3 4])

YUCK. Reader macro for lists implied. I could write it without the reader macro but I don't have the autism to muster.
>>
is there a faster way to do the C-x } command in Emacs?
it sucks putting in that command like 20 times
>>
glibc malloc:
void *
__libc_malloc (size_t bytes)
{
mstate ar_ptr;
void *victim;

void *(*hook) (size_t, const void *)
= atomic_forced_read (__malloc_hook);
if (__builtin_expect (hook != NULL, 0))
return (*hook)(bytes, RETURN_ADDRESS (0));
#if USE_TCACHE
/* int_free also calls request2size, be careful to not pad twice. */
size_t tbytes = request2size (bytes);
size_t tc_idx = csize2tidx (tbytes);

MAYBE_INIT_TCACHE ();

DIAG_PUSH_NEEDS_COMMENT;
if (tc_idx < mp_.tcache_bins
/*&& tc_idx < TCACHE_MAX_BINS*/ /* to appease gcc */
&& tcache
&& tcache->entries[tc_idx] != NULL)
{
return tcache_get (tc_idx);
}
DIAG_POP_NEEDS_COMMENT;
#endif

arena_get (ar_ptr, bytes);

victim = _int_malloc (ar_ptr, bytes);
/* Retry with another arena only if we were able to find a usable arena
before. */
if (!victim && ar_ptr != NULL)
{
LIBC_PROBE (memory_malloc_retry, 1, bytes);
ar_ptr = arena_get_retry (ar_ptr, bytes);
victim = _int_malloc (ar_ptr, bytes);
}

if (ar_ptr != NULL)
__libc_lock_unlock (ar_ptr->mutex);

assert (!victim || chunk_is_mmapped (mem2chunk (victim)) ||
ar_ptr == arena_for_chunk (mem2chunk (victim)));
return victim;
}


OpenBSD malloc:
void *
malloc(size_t size)
{
void *r;
struct dir_info *d;
int saved_errno = errno;

d = getpool();
if (d == NULL) {
_malloc_init(0);
d = getpool();
}
_MALLOC_LOCK(d->mutex);
d->func = "malloc";

if (d->active++) {
malloc_recurse(d);
return NULL;
}
r = omalloc(d, size, 0, CALLER);
d->active--;
_MALLOC_UNLOCK(d->mutex);
if (r == NULL && mopts.malloc_xmalloc)
wrterror(d, "out of memory");
if (r != NULL)
errno = saved_errno;
return r;
}
>>
>>61530926
Just make a macro for it :^)
>>
>>61530931

musl malloc:
void *malloc(size_t n)
{
struct chunk *c;
int i, j;

if (adjust_size(&n) < 0) return 0;

if (n > MMAP_THRESHOLD) {
size_t len = n + OVERHEAD + PAGE_SIZE - 1 & -PAGE_SIZE;
char *base = __mmap(0, len, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
if (base == (void *)-1) return 0;
c = (void *)(base + SIZE_ALIGN - OVERHEAD);
c->csize = len - (SIZE_ALIGN - OVERHEAD);
c->psize = SIZE_ALIGN - OVERHEAD;
return CHUNK_TO_MEM(c);
}

i = bin_index_up(n);
for (;;) {
uint64_t mask = mal.binmap & -(1ULL<<i);
if (!mask) {
c = expand_heap(n);
if (!c) return 0;
if (alloc_rev(c)) {
struct chunk *x = c;
c = PREV_CHUNK(c);
NEXT_CHUNK(x)->psize = c->csize =
x->csize + CHUNK_SIZE(c);
}
break;
}
j = first_set(mask);
lock_bin(j);
c = mal.bins[j].head;
if (c != BIN_TO_CHUNK(j)) {
if (!pretrim(c, n, i, j)) unbin(c, j);
unlock_bin(j);
break;
}
unlock_bin(j);
}

/* Now patch up in case we over-allocated */
trim(c, n);

return CHUNK_TO_MEM(c);
}
>>
>>61530940
>>61530926
never-mind, figured out how to do it with the mouse with click and drag
>>
>>61528012
Update your compiler.
>>
>>61530977
>needing a mouse to navigate your TE
Emacshit
>>
>>61528059
Are you fucking retarded?
GCC is already pretty compliant with C++17, much more with C++14 and especially C++11.
Get fucked retard.
>>
>>61530992
;~;
>>
>>61530999
Just switch to something else and free yourself from the commieware
>>
>>61530291
What? You can write a simple kernel with memory allocation in C.
>>
>>61531009
nothing else is as comfy for lisp/scheme tho
>inb4 lisp
i'm learning it so I can embed scripting capabilities into some C++ I'm working on
>>
>>61530926
If you want to do it 20 times,
M-20 C-x }
>>
>>61530818
Shen
>>
>>61531087
thx f a m
>>
File: nvm i fixed it.jpg (78KB, 460x566px) Image search: [Google]
nvm i fixed it.jpg
78KB, 460x566px
>>61530977
>>
>>61531111
nice quads my nibba
>>
>>61531111
>solition
>>
>>61528513
>while {} pretty much always does what you expect
This is incorrect.

Foo{1, 2}

This code could,
A: Call a constructor taking 2 ints
B: Call a constructor taking an initializer_list
But this is mostly just a problem in generic code.
>>
>>61531143
we didn't get a single sell
oy vey
>>
>>61531024
What does emacs have over vim and a screen multiplexer? Or vim and a repl plugin I suppose.
>>
Will I get fired for iterating over C strings like this

for ( ; *str; str++) {
}
>>
>>61531233
emacs has all that shit built in
i just go
C-x 2
C-x-C-f filename.scm
C-x o
C-u M-x run-scheme csi
and bam, I have a REPL and a source file to work in. all without any plugins or outside shit needed
>>
>>61531235
No, that's considered the natural way to iterate over strings in C.
>>
>>61531254
Is C-x CTRL-x?
>>
>>61531280
yeah
and M-x is alt-x
>>
Bump Limit
>>
>>61531305
no u
>>
>>61531305
It's 310, newfag.
>>
File: ???.gif (133KB, 437x441px) Image search: [Google]
???.gif
133KB, 437x441px
>>61531315
>>61531321
>>
>>61531254
That doesn't really sound like an advantage though when you have to install evil to make emacs good to edit in.

I'm wondering what it has over vim + a multiplexer. I already have the multiplexer anon.
>>
>>61531280
thats a lot of commands just for a file and repl desu.
Its just C-k-o to open a folder which opens a terminal in the dir.
or C-n C-s C-'-' to focus the terminal
Emacs seems like a lot of work
>>
>>61531350
>when you have to install evil to make emacs good to edit in.

>implying
>>
>>61531353
>>61531295
>>
>>61530017
>>61530840
I think you need to check both 8 bit and 16 bit uints.
I'm assuming that you're advancing by 1 byte each iteration of the for-loop.

uint8_t *sample = &example[offset];
for (; sample < end; sample += bytes) {
if ((*sample != x && depth != 16) || (*reinterpret_cast<uint16_t*>(sample) != x && depth == 16)) {
test = true;
break;
}
}


You might still have to check that
sample + 1 < end
if you're advancing by one byte each time and checking 16 bits.
>>
>>61531392
I don't want the check done every time (it won't change mid-loop). It's already known which it is long before this loop executes, and it shouldn't need to be checked literally 300,000+ times.

Ideally it's one loop, but maybe it'll have to stay two. I don't know.
>>
New thread:

>>61521295
>>61521295
>>61521295
>>
>>61531768
interesting move
>>
>>61531768
Good one.

Actual new thread:
>>61531837
>>61531837
>>61531837
>>
>>61529875
Source?

>>61529973
>>>>/cm/
cm is good
Thread posts: 314
Thread images: 21


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