Old thread: >What are you working on, Sup Forums?
/dpt/ - Daily Programming Thread
Other urls found in this thread:
forum.nim-lang.org
ideone.com
twitter.com
1st for winapi headers are a shit
One faggot forgets the title, another posts a non-programming related pic
Congrats dumbasses
because the trap faggot anime pictures are programming related
>non-programming related
Lies
You were just in the last thread saying macros in general are bad
That is wrong
Macros are great because you can solve problems before compilation and pre-bake the solutions into the resulting program
I only wish C's preprocessor was independently Turing complete
I don't recall saying I liked those either
Dropping parens is retarded, and it becomes even MORE retarded when your language allows shit like fn arg instead of fn(arg)
(fn arg) master race
what does
f a, b c, d, e, h mean?
Sounds like you actually want metaprogramming and not a preprocessor.
How de we revive /prog/, lads?
create it
seems like you want to upgrade to c++17
In an (fn arg) language, that looks like ass. Here's how it should be written:
f a ,b c ,d ,e ,h
It's only valid in a quoted list. And here's what it means: the list should contain the symbol f, the symbol a, the value of b, the symbol c, the value of d, the value of e, and the value of h.
C++17 doesn't have a Turing complete preprocessor either
>(fn arg) language,
Nope
forum.nim-lang.org
That's not an (fn arg) language. That's an fn arg language.
i dont understand non-c style syntaxes
am i a brainlet?
What is the popsicle meme
because it has a superior alternative
That's what I said though
Probably because you are used to exploit whitespace insensitivity. It's not a bad thing.
Shit like Ruby gives brain damage
He's thinking about templates. Which is pure madness. Macros are much better for that kind of stuff. Sure they're not Turing complete but they solve most non-generics tasks better.
Fucking moron.
No it doesn't.
Given that templates, constexpr, auto, decltype, and all those things combined are not Turing complete, how can they be superior to a hypothetical preprocessor that IS Turing complete?
>Fucking moron.
Fucking brainlet.
>Shit like Ruby gives brain damage
Can your language do this>
30.times {
# do something
}
Nah it's just something you need to learn all over. Declarative languages can be especially confusing.
>That's what I said though
No, you said an (fn arg) language. And then you linked to an fn arg language. You can't treat them interchangeably, they're two completely different things.
>Given that templates, constexpr, auto, decltype, and all those things combined are not Turing complete,
what makes you believe so?
>>(fn arg) language,
>Nope
Templates are Turing complete and it's awful what people force them to do.
And the compile times for that shit makes you think you should sit down and spend that compile time on writing actual metaprogramming replacements for your templates.
Stop bitching about how terrible it is and make an actual effort to make good posts.
I misunderstood you. I thought you were saying "Nope" as in "yes it is an (fn arg) language, and no that is not what it means," not "no it is not an (fn arg) language." But given that you meant "no it is not an (fn arg) language," your prior response () makes no sense as a response to the post it was responding to ("(fn arg) master race").
Well I mean they aren't
>Templates are Turing complete
No
(just kidding lads i am troll)
for (int i=0; i
HURR HURR DURR
forach(_; 0..30)
//do shit
You're clearly not asking if other languages have for loops.
What is it you're looking for?
Thanks for proving his point
Expressiveness
I Ruby
See
then
for(expression;condition;expression) {block}
>condition
Well actually that's an expression as well it just should evaluate to something that's a condition realistically.
30 `times` do
something
>See
>
That's the exact opposite of expressiveness, mongrel
Yes.
#define times(x) for (int i = 0; i < x; i++)
times(30) {
/* Do something */
}
emoji get stripped reddit cuckboy
>opposite
It's easy for the machine to read.
It's easy for real humans to read.
What's your problem?
Especially when it's not the trivial circumstance of an indexed loop.
Thought this was a joke because rub sounds a little like love and y can imply you.
times n io | n > 0 = io >> times (n - 1)
| otherwise = return ()
main =
30 `times` do
putStrLn "Hello"
putStrLn "World"
Could make it have an index parameter, maybe possible to make that optional using type classes
>It's easy for real humans to read.
As opposed to that example? Stop reaching for the straw, dude
Okay, now can your language do this? (this language is still Ruby btw)
define_method(:can_your_language_do_this?) {
Trait = Class.new(Module) {
define_method(:state) {|&block|
old = method(:extended)
define_singleton_method(:extended) {|obj|
old.call(obj)
obj.instance_eval(&block)
}
}
}
has_a = Trait.new {
attr_reader :a
state {
@a = 1
}
}
has_b = Trait.new {
attr_reader :b
state {
@b = 1
}
}
has_c = Trait.new {
define_method(:c) {
return @a + @b if @a && @b
}
}
obj = Object.new
obj.extend has_a
obj.extend has_b
obj.extend has_c
puts obj.a.to_s + ' + ' + obj.b.to_s + ' = ' + obj.c.to_s
}
can_your_language_do_this?
I don't know what trait is, also I may have a different concept of Modules than Ruby's
>It's easy for real humans to read.
Perhaps that could be a subjective matter.
There's plenty of brainlets that post here on the regular. :^)
>as opposed to that example
That example could imply any number of things. The for construct in C is very explicit. But sure, you could assume that 30.times doesn't mean you've declared a multiplication on the result of the block.
If I wasn't quite sure you were aiming to do something like a for loop that could easily be the case.
It'd be quite a nice feature actually.
>OOP
Ruby doesn't actually have (stateful) Traits, Ruby has Modules which are basically Traits but stateless. A Trait, as I've defined it here, is pretty much just a mini-class that supports multiple inheritance and is written with this in mind by being minimal and modular in what functionality it supplies to the derived class.
What I've done here is I've implemented traits in Ruby as an extension of modules, and then I proceeded to use them to say 1 + 1 = 2.
When I speak to "brainlets" they say 30 times this or 30 times that, maybe only mentally ill Cpeepee autists say for int i 0, if i less than 30 do this and increase i
u r dum
To be more clear. What you wrote could be:
argument1.operation {
expressions;[...]
return argument2
}
Maybe even allow for multiple returns. I'd really like that actually.
I'm sure anyone with half a brain can see how useful this is for reducing mental overhead. It's very clear where the effects of this piece of code will be.
lol autist
>"can your language do [simple thing]?"
>yes! yes it can! btfo lol!
>"can your language do [complicated thing]?"
>WAAAAH ITS OOP NO FAIR WAAAAAAAH MUH PURE-A-TEE WEHHHH BLUB BLEB BLURB BUH HUH HUH
>yfw
It can but I'd never do that. That's horrible.
>normal-order evaluation
please, don't.
times(--x) { }
times(f()) {}
...
I don't even know what inheritance is. Try again.
Try avoiding these shitty concepts:
Interface, Encapsulation, Inheritance, Polymorphism etc
>It can
I don't believe you.
Unless you're talking about C++. C++ can do anything, and that's both the best and worst thing about the language.
>I don't even know what inheritance is. Try again.
Inheritance is when a record that contains a record of another type can be treated as directly containing all of that type's fields, and can be non-mutatively cast to that type.
>shitty concepts
See:
It is C++ and I agree. But you could do the same in C actually. It's a very large piece of code though.
>show me how
It's just too much to explain. But it's certain within reach since we don't have implementation constraints.
OOP is bloatware plain and simple.
Pretty much everything OOP can accomplish can be implemented with purely imperative structures that fundamentally runs with less overhead.
But sure, you keep using your script kiddy language and hope people will take you seriously.
>shitty concepts
Yes they are, your language is written without it
>OOP is bloatware plain and simple.
Abstraction is bloatware plain and simple.
>Pretty much everything OOP can accomplish can be implemented with purely imperative structures that fundamentally runs with less overhead.
Pretty much every limb on my body can be cut off to make me lighter.
>But sure, you keep using your script kiddy language and hope people will take you seriously.
I don't have to hope, I live off merit scholarships.
>Yes they are, your language is written without it
see:
Does this mean the package is unusable right now?
oop is neither about imperative nor declarative
>purely imperative structures that fundamentally runs with less overhead.
wrong, oop actually gives more optimization rooms for when dynamic resolution is involved.
>see:
Why should someone "solve" a problem that simply does not exist in the first place?
the master branch yeah
but there's probably a stable tag/branch that you can checkout
>
see:
...
Simply ebin.
Why would someone accept a commit that actually breaks shit?
c-can I get free (you)s too?
No
because some people use the master branch as a development branch so it might be a partial progress
don't ask me
see:
Deferred ARC
It's all a matter of what you consider a problem. Go right ahead and continue using assembly if you don't like the changes introduced in C. Same story with OOP vs pure imperative, same story with traits vs OOP.
>if you don't like the changes introduced in C
Doesn't apply to me.
>Same story with OOP vs pure imperative, same story with traits vs OOP.
Neither do these
I struggled for two days with k&r's exercises 1-13 and 1-14. Am I literally retarded or is the book hard?
Why is meme?
Now can your language do this?
int i = 60;
times(30) {
i--;
}
printf("%d\n", i); // should be 30
Learn to use libraries faggot
Can anyone tell me why the fuck one would do smth like this in Java.
public class Person extends ArrayList
An object that at the same time is a list of objects of its same type?
This kind of brainfucks me.
How would one use this?
>What are you working on, Sup Forums?
Exploring the deepest, darkest corners of Racket (0﹏0 ;)
#include
template
void times(unsigned n, F f)
{
while (n --> 0) f();
}
int main(int, char **)
{
int i = 60;
times(30, [&]() { --i; });
std::printf("%d\n", i);
return 0;
}
>a person is several people
Sounds like an abuse of inheritance personally.
kek
What the fuck?
It compiles?!
I didn't expect it to work but given that it does work I can tell you people probably use it as a simple way of implementing a tree data structure. Think about this: each Person is an ArrayList, and each member of that ArrayList is also an ArrayList, and so on. So it forms a tree.
How dare you.
You're just (You)sing me.
>while (n --> 0)
This is fucking brilliant
yeah it's the "goes to" operator :^)
my heart goes out to all the survivors of _____
and then my heart goes out to mcdonalds
and then my heart has an attack
are nice person