/dpt/ - Daily Programming Thread

C is the greatest programming language of all timd
Previous thread:

Attached: c.jpg (196x258, 9K)

Other urls found in this thread:

gitgud.io/n02/booruclient
stackoverflow.com/questions/15327706/c-currency-output
twitter.com/SFWRedditImages

first for C++

what books should I read to learn programming in unix?

second for java :3

daily reminder that Rust will never see widespread adoption because it's too hard to understand for the average programmer

show your sucks fagboi.

How come put_money doesn't add a 0 on the front? Is there an easy way to fix this or am I gonna have to do a shitty hack?

int value = 50;

std::ostringstream stream;
/* Make a new locale with an empty string, this uses the users locale */
stream.imbue(std::locale(""));

stream

>it's too hard to understand for the average programmer
fantastic, that means less competition.

c, c++, or c#?
if c#, use the string.format() function to get it the way you want it

what does this :: do ?

C++, this function works perfectly aside from this one little issue, ofc I could make my own but I don't want to deal with locales.

It's used to take a function from a namespace, so std::put_money(value) is calling the function put_money from the namespace std. You can add using namespace std at the top of your file to just enter put_money but it's not recommended because it pollutes the global namespace

>it pollutes the global namespace
you should use "using" if it makes your job easier

If you think your users are idiots, only idiots will use it.

Attached: Linus-Torvalds.jpg (800x400, 162K)

Why do people that clearly are balding continue to have awful hair until they eventually only have a monkring on their head?

thanks user.

*differentiates a tree*

>monkring
the word is tonsure you fucking illiterate

i don't care :^)

because baldies are revolting

Booruclient update. gitgud.io/n02/booruclient
I've added a few features and I've also made the build process more retard-proof. The git soymodules were removed.
Now it's possible to add more sites, and to configure a proxy. There are also some minor UI additions. I welcome any requests for new features.

Attached: 4159412.png (1041x912, 643K)

Working my way through the book Programming Pearls right now, using mostly Javascript and Assembly to implement solutions to the various problems posed in the book.

Attached: 2018-03-25-224147_1920x1080_scrot.png (1920x1080, 225K)

using the whole std namespace is retarded, just select the namespace members you're actually going to use.

First off, perhaps you'd like to use float or double instead of int, or use ((double) value) / 100 when printing it to output.

Second: stackoverflow.com/questions/15327706/c-currency-output
In short, you can use to change how cout prints to the CLI.

>weebizing your code and WM

Attached: autism.gif (480x270, 528K)

I'm working on a wiki for org-mode that uses JSON exported from Webextension bookmarks to organize my 1000+ tabs into a personal wiki

I met Terry the other day

Attached: Spectacle.b10876.png (2842x813, 163K)

10 BASIC
20 IS
30 THE
40 BEST

GOTO 10

Why doesn't /dpt/ keep a thread count?

GOTO 11
What now faggot?

my only weakness....

Because we aren't nearly as autistic as /ksg/

reminder that C has dependent types
enum heresadependenttypefaggots {
NINE = 9, TEN, ELEVEN, TWELVE
};

it's an unchecked dependent type but still

t. retard

t. moron
9, 10, 11 and 12 are all enum heresadependenttypefaggotses
anything less than 9 or greater than 12 is not

you have absolutely no idea what dep types even are.

sure i do, they're subtypes defined by predicates on values of the supertype. e.g "integers greater than or equal to 9 but less than or equal to 12" is a dependent subtype of "integers."

>they're subtypes defined by predicates on values of the supertype

Attached: grad.png (2154x2167, 200K)

based retard.
an enum isn't a dependent type.

>t.
mämmi sauna

That's a refinement type. It's not dependent at all. You are confused because you can implement refinement types with dependent types, e.g. an integer between 9 and 12 is an integer i with a proof of the type 9

Well, they are.
>In computer science and logic, a dependent type is a type whose definition depends on a value. A "pair of integers" is a type. A "pair of integers where the second is greater than the first" is a dependent type because of the dependence on the value.
>Two common examples of dependent types are dependent functions and dependent pairs. A dependent function's return type may depend on the value (not just type) of an argument.
C also has dependent functions:
enum heresadependenttypefaggots inttohadtf(int i) {return i;}

This will return an enum hereseadependenttypefaggots if the parameter is within the range of that type, and an integer otherwise -- though the integer returned otherwise will still be erroneously considered an enum heresadependenttypefaggots by the compiler.

Enums are indeed dependent types. They are types that depend on values. Namely, the definition of the enum depends on the values of the first and last elements of the enum.

1) You mean a refinement type
2) Enums with a false start are not even a refinement type
3) "it's a different type the type system just doesnt notice it" is not a valid claim

A dependent type would be this:
// notice how the i in the return type, is one of the function parameters
greaterThan addOne(int i) { ... }

a refinement type would be this
fourToSeven = { n : int, n > 3, n < 8 }
// notice how it does not depend on another value, it is simply an existential pair
// in other words it's a constrained type

Depending on a value is not the same as being defined in terms of a constant.

Unironically the elisp section of the emacs info mode along the ielm mode.
Nothing beats interactive programming, ipython is nice too.

Attached: 2018-03-25-224526_1600x900_scrot.png (1600x900, 70K)

dependent types aren't about fucking values you brainlet, they are about types

the : (ty : Type) -> ty -> ty
the ty x = x


A simple Idris function to specify a type.

>// notice how it does not depend on another value
It certainly does. In fact it depends on two other values: 3 and 8.
Indeed, since the latter is a stronger claim, encompassed by the prior weaker claim -- since constants are values.

That's just a dependent type that depends on a value that is a type.
You can also have dependent types that depend on values that are not types. These values may be variables, but not in C, where they must always be integer constants.

For example:
void function(int n, float arr[n]);
if you curry this function, you get
(n : int) ->
(float[n] -> void);
notice how the return type depends on the input?

It isn't a dependent type whether you like it or not.
It doesn't even depend on the constant, that's purely runtime representation.

>3) "it's a different type the type system just doesnt notice it" is not a valid claim
It is though. There are plenty of things in C that the ___ system doesn't notice but which is nonetheless a different ___. Hence the existence of undefined behavior.

>that depends on a value
it does not depend on a value you mong.
You have absolutely no idea what you're talking about.
Idris> the Int
id : Int -> Int


This will be your last (You) from me.

>notice how the return type depends on the input?
Yes, which is a value.
3 and 8 are also values.
>It doesn't even depend on the constant, that's purely runtime representation.
It does, though, the compiler just doesn't have to account for that.

>it does not depend on a value you mong.
The type of "the Int" depends on the value Int, which is a type.

It's hard to argue with someone who has an IQ below 90. "it's there so long as you imagine it to be"
You can't even tell the difference between a type constructor and a dependent type. And C doesn't even have a concept of type constructors, it just has built-in rules for introducing types using other types and constants.
For instance, Haskell has the type constructor (->), but simply typed lambda calculus does not. Yet both have function types (T1 -> T2). C doesn't even have variables in types, thus none of its types are dependent types. Trying to pretend that it's just whatever bullshit meaning you can force out of "depend" is retarded.

I have my c++ repository on a Gitlab with cmake (gitgud.io).
Is it possible to set up a CI on the remote which automatically builds windows release packages? I have little knowledge about such things, just asking.

>And C doesn't even have a concept of type constructors
>struct
>union
>(*)(
>*
>const
>volatile
>register
>auto
>static
>extern
>inline
this is C's very limited selection of type constructors

I like to put "using namespace std" in headers where I would rarely touch like the matrix class I wrote the other day

yes

>C doesn't even have variables in types, thus none of its types are dependent types.
conclusion doesn't follow from premise
dependent types need not depend on variables, they need only depend on values

Ok nice to know, but how. How do I have access to mingw and shit

>I like to put using in headers
how about you kill yourself?

>everybody should feel as insecure as I do, it's not fair!

meant for

None of those things exist "in the wild".

Consider my example
In the simply typed lambda calculus:
T ::= o | T -> T
You can abstractly consider -> to be a type constructor with two arguments, but that isn't part of the type system. While in Haskell, (->) really is a type constructor with kind (* -> * -> *).

So you can think of them as type constructors, but the system itself doesn't have a notion of type constructors

It's not dependency if it's a constant you mong

literally just implement "the" in C without hard-coding everything if you want to prove C has dependent types.

>mong

well i mean the system itself doesn't have a notion of dependent types either and yet:
enum {...};
sure it is, it's just a very limited kind of dependency

No it fucking isn't

#define the(T) T (*)(T)

sure it is, it's just like how a line segment is a degenerate case of a triangle

You don't "access" MinGW. You set up a runner file and select a docker image and instruct the build how to process it. Then you set up a shared runner in the settings (or you can supply your own). Just Google "GitLab Runner".

1) That WOULD BE a type lambda, not a dependent type
2) Macros aren't part of the type system

use common::sense;
>perl does not use common sense by default, you have to install it

>C has dependent types
Jesus fucking christ...

Attached: 1521912231368.jpg (638x558, 63K)

Thanks now I have an idea where to start

there is no brainlet picture that can do this conversation justice.

>1) That WOULD BE a type lambda, not a dependent type
it's literally no different from the: (ty: Type) -> ty -> ty except done in a language where functions don't curry and types aren't values
>2) Macros aren't part of the type system
enum bounds checking isn't part of the type system either and yet 2 is not an enum {X = 3, Y, ...}

dumb wojakposter

>it's literally no different
It literally is different, it's
\(ty:Type). (ty -> ty)
Lambdas =/= pi types

>dependent types need not depend on variables
Formally, a dependent type comes from a judgement x: A |- B(x): Type. x is a variable, not a value. Values only come in through substitution.
x: A |- t: B(x)
|- a: A
---------------
t[x:=a]: B(a)

x - variable
B(x) - dependent type
a - value

C has first order statements in the specification, but not in the type system.

i don't know what that expression means but you're right it is different, my implementation of "the" returns the type ty -> ty, yours returns a value OF the type ty -> ty
here is an actual implementation:
#define the(T, x) ((T) x)
anyway C still has dependent types, it's just that said types can only depend on constants

int getInt(){
int i = 5;
return i;
}

int main(){
int j = getInt();
return 0;
}


Does i get deleted, since it's out of scope?

B(a) in this case is not a dependent type, by the way; it's now a constant type, because it has no free variables. B(x) where x is a variable is the only dependent type.

C still has dependent types tho
x: unsigned long long |- B(x): enum {EID1 = x, ...}
with the additional restriction that x must be a literal or a macro expanding thereto

>B(a) in this case is not a dependent type, by the way; it's now a constant type, because it has no free variables. B(x) where x is a variable is the only dependent type.
sure it is, x is still a variable where x = a
it's a variable that can have a number of various values
that number is 1 and the various values are a

Julia 0.7/1.0 is truly the language of the gods. I'm playing around with the master branch atm. It's a bit behind schedule, but it should be released any time now.

It's just a lambda
the(ty : Type) = ty -> ty
What you mean is:
the(ty : Type)(x : ty) = x
Notice how "ty" appears inside the type of the second parameter. BUT, this is still not a dependent type, this is simply a type abstraction: ΛT. λx:T. x
With the type: ∀T. T → T
In order for it to be a dependent type, you would need a term to appear bound inside of a type

You need to investigate two concepts: pointers and the use of the static keyword to provide permanent storage to returning functions.

are you a real nip or a weeb?

- while in this case, it's simply a term depending on a type, rather than a type depending on a term.

what makes julia great?
Also the intense shilling lately is a little obvious considering there's been no code posted.

The definitions of "dependent type" and related concepts are formalized in logic and category theory. They are not pliable and open for interpretation like you seem to think they are.

it's just one guy, move on

But they do encompass a degenerate case in which the type of the variable contains exactly one value.
C supports that degenerate case.
Ergo, C "has" dependent types.
Just like one dimensional spaces "have" triangles.

BASIC is the greatest programming language of all time

there is no variable

@ Cposter:
if you really wanted to argue C has dependent types why did you use enums and not VLAs

>C arrays
That'd be an ever weaker case compared to his current delusion.