« first day (1458 days earlier)      last day (3484 days later) » 

7:00 PM
@Ell Nope
 
@Ell No.
@rightføld I think you might have needed 0,0,0,1
 
user1804599
val elseValue = codegenBranch(thenExpression, thenBlock) oops lol
 
lol
 
@rightføld Hmmm....perhaps alloca {i18n, i1}* would help (internationalization in one easy step, right?)
 
user1804599
Yaycakes it compiles if expressions iff they are well-typed.
 
7:06 PM
you can alloca { i18, i1 }*
 
@Puppy Better still.
 
user1804599
@AndyProwl more horror ^^
 
@rightføld beautiful :P
 
What is the downside to using "using namespace std"
A lot of people warn against it
and say its better to use std::cout
 
7:08 PM
name clashes
 
names fight against each other when given the chance
 
Is there any security issues with it though?
 
user1804599
574
Q: Why is "using namespace std;" considered bad practice?

akbiggsI've been told by others on numerous occasions that my teacher was wrong in saying that we should use using namespace std; in our programs. Hence, we should use std::cout and std::cin and these are more proper. However, they did not even make it clear ever why this is a bad practice. Why is usin...

 
the programmers get the collateral damage
 
user1804599
@AndyProwl thanks
 
7:09 PM
Thanks @rightføld. I appreciate it
 
if you call the wrong function by accident and it builds, there is a problem for correctness, which is worse
 
user1804599
ADL called.
 
@rightføld This is exactly what I started saying. You can pull in std functions by accident in a lot of cases without using namespace std.
 
user1804599
Explicit adl operator rather than implicit ADL would be nice IMO.
 
true, but why would one make things even worse and import all names from std, indiscriminately
 
7:12 PM
I don't understand what people mean by "language security".
Like "Is there any security issues with using namespace std;".
 
IMO overloading is overrated. If I were to design my language, I wouldn't allow overloading functions.
 
I don't get it.
 
user1804599
@Sofffia I love it when people claim Java is the best language because it doesn't have pointers, not realising there are other languages than C, C++ and Java.
 
I stopped using using namespace std; afer I wrote my own header file for the first time.
 
user1804599
@AndyProwl I allow overloading on dynamic type and only functions marked as overloadable can be overloaded.
 
7:13 PM
@Sofffia a possibility may be: if you end up calling the wrong function due to a using directive and your program builds and your unit tests don't catch the problem, you might have an issue with security
 
user1804599
Overloadable functions can also be marked sealed which means they cannot be overloaded outside of the module in which they are defined.
 
Writing std::string in one place and string in another was annoying enough.
 
@AndyProwl Can that be really called "security"?
 
And using namespace std; in header file is evil enough for everyone to see.
 
@Sofffia depending on what the called-by-mistake function does, I guess it might, but... just trying to play the devil's advocate
 
7:15 PM
std::x is sexier than x, forall. x
 
@rightføld but why is overloading better than, say, simpler forms of polymorphism like type classes or run-time concepts?
 
@Ell is std::magic a function?
 
every time I take a look at C++'s overload resolution rules I want to cry
 
user1804599
@AndyProwl Type classes provide a way to overload.
 
user1804599
Similarly, you are explicit about which functions can be overloaded.
 
7:16 PM
right, I mean why isn't that a better form of polymorphism?
resolving a function call is much simpler
 
there's no absolute better in programming
 
@AndyProwl your loss for not learning to look away
 
no ADL stuff
 
user1804599
Never said it wasn't.
 
user1804599
Though I'm not sure how well type classes work with subtyping.
 
7:17 PM
@sehe sometimes you have to look into the beast's eyes
 
user1804599
It's possible to do both type classes and subtyping in Scala so I might check that out one day.
 
@AndyProwl Yeah. After you killed it (or drugged it)
 
user1804599
But I don't think it allows overloading on dynamic type, unless you make the type class instance a member but that defeats the whole purpose of type classes.
 
@AndyProwl If you have overloads where it actually matters which overload gets called in a given circumstance, then you're abusing overloading and you get what you deserve. Overloading should be used when all the overloads are functionally identical, and you're mostly just preventing casts (and such) in calling what's logically a single function.
 
7:18 PM
@Sofffia but there's absolute "fucking more complicated"
@JerryCoffin I agree, but the probability of getting things wrong is quite high, with ADL, using directives, etc. Without overloading there would be none of those complications. At least that's my naive understanding at the moment
 
user1804599
And there's C++.
 
user1804599
If C++ didn't have overloading you could still emulate it to some extent using templates.
 
YAY I'M THE BUS DRIVER
 
@AndyProwl I dunno. Personally, I tend to use overloading in fairly simplistic ways that have never caused me a problem. I can see, however, where (for one example) somebody with ill intentions could pretty easily add overloads that did bad things without changing externally observable behavior. E.g., you have code that takes a credit card number as std::string const &, but typically pass a char const *, and depend upon implicit conversion.
 
user1804599
So, yay it compiles let main (env: int): int = if true then 1 else 2.
 
7:25 PM
I add a version that takes char const * directly, saves everybody's numbers for my use, and then explicitly creates a std::string and passes it to the original overload. Edit that into some seemingly-unrelated header of string utilities (or whatever) and it could probably be in place for a long time without anybody noticing.
 
user1804599
Decided to go with = instead of be after all.
 
Arguably, that's as much a fault of allowing implicit conversions as of overloading though.
 
@JerryCoffin I see what you mean. I wasn't thinking of a malicious user though, more about how hard it is to wrap your head around the 1337 rules considered that alternative and simpler mechanisms exist. For instance, I sometimes still get surprised by simple programs that invoke an overload I don't expect (yes mostly because of implicit conversions)
of course I do end up figuring out what's going on and almost always learning the lesson, but it shouldn't take that much effort
but you're right, implicit conversions are responsible for most of the gotchas
 
@rightføld The semicolon stuff there is horrible
 
user1804599
There are no semicolons there.
 
7:30 PM
Wait, what do you call ":"?
 
I think I've read Bjarne saying that if he could go back, he would probably disallow them, but at the time it looked the clever thing to do because C
 
user1804599
A colon, noob.
 
user1804599
Like the stuff your shit is created in.
 
Yeah, the colon stuff there is horrible
 
user1804599
Why?
 
7:30 PM
(btw it's not horrible in the program above)
 
user1804599
I don't plan on doing type inference for function parameters.
 
@AndyProwl I don't see any way he could have hoped to maintain any compatibility with C and still prohibit (even a substantial percentage of) implicit conversions.
 
indeed
 
user1804599
Only for return types, but I still have to implement that.
 
Because you are using : for two different things
inb4 the return type is still a type or something
 
user1804599
7:33 PM
No, I don't.
 
So x : y says x is of type y, correct?
 
user1804599
: indicates data type.
 
user1804599
Yes.
 
user1804599
Cons is ::.
 
So, how do I define the type of the function main?
 
user1804599
7:33 PM
int -> int
 
is let even necessary?
 
main : int -> int?
 
user1804599
But with let the type is inline with the parameter list.
 
user1804599
@Sofffia Yes.
 
user1804599
@AndyProwl I like keywords before top-level definitions. No idea why.
 
7:34 PM
I see
 
So why are you using main (env: int) is of type int instead of saying main : int -> int?
 
Xeo
52 secs ago, by rightføld
But with let the type is inline with the parameter list.
Not hard to understand.
 
"Creative Coding" from cppcon is quite a nice talk
 
user1804599
It's pretty much the same as in F#.
 
You guys are not understanding what I mean
But it doesn't matter
 
user1804599
7:36 PM
You can say let main: int -> int = fn env => … if you want. :v
 
user1804599
At least, when I implement lambdas.
 
user1804599
Also, main will be of type Environment -> ExitStatus in the future, so no need to worry about : int. :P
 
is it a functional language?
 
ExitStatus?
 
can functions return void?
 
7:38 PM
Why not throw exceptions or something like that?
 
user1804599
@AndyProwl If your definition of "functional language" includes impure languages with strictness, then yes.
 
user1804599
@AndyProwl No, but they can return unit.
 
Exit codes seems out of character for you
 
@rightføld Basically I was preparing the ground for asking what Jeffrey asked
if the function can return void, you may just signal failure by throwing exceptions
 
user1804599
@Sofffia yes, that value you return to the OS.
 
user1804599
7:40 PM
Environment includes stuff like command line arguments, environment variables, the file system, the network, the system clock, etc.
 
user1804599
Because fuck globals.
 
Ell
@rightføld I think this is good
 
I like that too
 
Oh, and I forgot to mention: it looks like you're really over complicating things badly. You should probably just use a fix signature signal<void()> to which you then connect bound handlers (using boost::bind or c++11 lambda expressions). Then you can simply drop the any+any_castsehe 3 mins ago
Either that, or don't try to make emit more generic than it is:You are having to duplicate the expected argument types on all call sites now, that's a Bad Idea(TM) and a code smell. Why not just void emit1(int,double) and void emit2(ip_stats_t&) and avoid all of the fake dynamism and maintenance nightmare of invoking emit<> by explicit template arguments? — sehe 47 secs ago
 
user1804599
Only violator will be std.debug.
 
user1804599
7:42 PM
WHICH IS ☆MAGIC☆
 
why doesn't that fit in Environment?
 
. is for modules?
 
@rightføld That's a good line for sex offender defense lawyers: "Clearly, my client didn't violate her. He just wanted some consensual debugging."
 
user1804599
@AndyProwl because I want to printf-debug in various places even if those places don't do I/O.
 
I see
 
7:43 PM
how do you printf-debug without I/O?
 
user1804599
And passing I/O facilities to them just to do debugging is inconvenient.
 
user1804599
I'll also warn when you import std.debug in release builds.
 
@Sofffia even Haskell does it
 
@Sofffia if he wants to trace stuff to see the steps of a pure function he would have to modify its definition and all its callers
 
user1804599
@Sofffia I mean functions that don't do I/O when you don't printf-debug them. :P
 
7:45 PM
@sehe No?
 
That's not what I call printf-debug
That's simply debug
 
it's tracing
 
@Sofffia What is that. Well, it has functions for that. I don't remember what name, but they work. And they don't require any explicit meddling with IO. (Of course they do IO but I assume you meant something slightly more meaningful)
 
you print formatted strings for debugging purposes
printf-debug may not be super-accurate but it's not far off either
 
7:48 PM
@Sofffia Which it isn't. Debugging would be known as "single-stepping". Trace doesn't, it just transparently echoes some value to output, while also returning it as the function result
@Sofffia By the way: "No?" really irks me. Arguments, baby.
 
@MartinJames More or less
Well, yes.
 
@sehe My argument was that there was no such a thing. It's hard to demonstrate that something doesn't exist without going trough all the modules in Haskell. On the other hand, if you believe X exists, you won't have any trouble showing it to me.
 
The Tavern is mucho depressing; I see enough shite questions daily on SO without having links to them spammed in my face every 10 seconds
 
user1804599
This is what hello world looks like in my current mental idea: gist.github.com/rightfold/0beb22fc2e79b25ea901
 
The way I intend "printf-debug" is a primitive form of debugging in which you "printf" variables and or specific points to debug your program. It's usually what you should learn to do the very first few days of programming. In Haskell the closest thing to "printf" is the "putX" family, which does I/O.
 
Ell
7:51 PM
@rightføld what is the type of "Hello World\n"?
String I guess.
 
@Sofffia So, "No?" is entirely too easy, too passive and too negative. You just said you don't know it. Why don't you say "I don't think there is", "I don't know about that, where is it?", "Can you point me to it?"...
 
user1804599
@Ell string
 
No, do not do this. Yuck. Yikes. Eugh! This is a terrible idea. You want a std::vector<float> wrapped by a type that performs 2D<->1D index translation for you. — Lightness Races in Orbit 10 secs ago
accepted, too -.-
 
user1804599
I don't plan string to be a list of code points or anything like that.
 
@sehe With "No?" it's implicit that I am the one thinking that your statement is wrong.
 
7:52 PM
@Sofffia So, it's not "printf debugging" because you say so it happens to be non-imperative code?
 
@rightføld Shockingly, that's not awful.
haha I forgot about sehe
 
@sehe So, it's "printf debugging" because you say so?
 
@Sofffia (Precisely. Next time. Are you trying to be the puppy?)
 
/me glances at the transcript
/me remembers why
/me forgets again
 
gives negative number of fucks
 
7:53 PM
slaps @LightnessRacesinOrbit with a large trout.
 
@Borgleader dem feels!
 
The fact that it's non-imperative code has absolutely nothing to do with anything.
 
Did you know, mIRC implements a XYZZY easter egg?
 
Okay
 
@LightnessRacesinOrbit i did not
 
7:54 PM
@Borgleader Do you now?
 
@sehe lol
@rightføld Implicit returns :3
 
Yeah. It's not worth arguing over
 
Of course it isn't.
 
I guess it's only printf if the function name is printf. I dunno. I don't do Haskell (pun intended)
 
> /xyzzy
If you type /xyzzy then mIRC will return the message "Nothing happens".
 
user1804599
7:55 PM
@Sofffia yes, there is an implicit return before the {.
 
user1804599
You cannot return early.
 
user1804599
@sehe Haskell has printf!
 
@rightføld before the {? what
 
user1804599
Yeah; { x; y; z } is like (x, y, z) in C++.
 
user1804599
And function bodies are expressions.
 
7:57 PM
@rightføld sssssh. I'm already traumatized
 
@rightføld like Haskell?
 
user1804599
No. In Haskell this doesn't make sense.
 
do { x; y; z } is x >> y >> z which is basically (x, y, z), no?
 
user1804599
It makes no sense in Haskell to evaluate x and y for their side-effects, ignore their results and return the result of evaluating z.
 
user1804599
Pretty much because Haskell expressions have no side-effects.
 
7:58 PM
wat
am I still alive
what's going on
 
user1804599
(x, y, z) in C++ evaluates x and y, ignores their results and then returns the result of evaluating z.
 
@Sofffia there's still science to be done, to make a neat gun... so you are... still alive
 
@rightføld Yes. In Haskell, as far as IO goes, there's an explicit operator for that: >>.
It's a monadic operator, which is much more general.
 
user1804599
Having such a feature in Haskell would be stupid, since evaluating an expression and ignoring its result is pointless.
 
user1804599
>> sequences monadic actions.
 
8:00 PM
@rightføld Not in the I/O monad?
 
user1804599
The result of x in x >> y is not ignored in Haskell.
 
user1804599
x is a monadic action.
 
Yes it is.
 
user1804599
No, it's definitely not.
 
user1804599
Again: ignoring the result of a referentially transparent expression is stupid since you could just as well not evaluate it in the first place.
 
8:01 PM
"x is a monadic action." -- "Yes, it is" -- "No, it's definitely not"
Are you ok?
@rightføld That wouldn't produce the side effects
 
user1804599
"No, it's definitely not" referred to x not being ignored.
 
> Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in imperative languages.
 
user1804599
@Sofffia All expressions in Haskell are referentially transparent and as such have no side-effects.
2
 
lol
 
user1804599
(Fuck unsafePerformIO—it's ignored in this discussion.)
 
8:03 PM
@Borgleader You may be too young to understand this reference.
 
@LightnessRacesinOrbit I wiki'd it. Never played that game.
 
@rightføld So you are saying that in main = putStr "lol" there are no side effects?
 
user1804599
Indeed.
 
@Sofffia not until you evaluate main I guess
 
user1804599
main is always the same I/O action, no matter how many times you run the program in different states your computer is in.
 
8:04 PM
@rightføld So... what do you mean by "producing side effects"?
Also can you please explain that quote to me?
 
user1804599
Now GHC creates a trampoline written in C that evaluates main and does some magic to make the I/O happen, but that's outside of Haskell.
 
user1804599
@Sofffia mutate state in an observable manner (e.g. doing I/O or setting errno).
 
@rightføld "Ignoring side effects, language L is free of side effects", seems to work about equally well for any language we choose.
 
@JerryCoffin I think he meant to say it's not idiomatic
 
@rightføld It's mutating the state of my terminal
Which is I/O
It can also set errno
Wow
 
user1804599
8:06 PM
That happens after evaluating main, not while doing so.
 
So?
The complete evaluation of main produce side effects.
 
user1804599
> newtype IO a = IO (State# RealWorld -> (# State# RealWorld, a #))
 
user1804599
main returns a value of this type, and it's always the same value, and that's all main does.
 
user1804599
Now what C does is invent some value of type State# RealWorld and pass that to it, but that's not interesting as far as Haskell is concerned.
 
@AndyProwl I think what he meant to say was closer to the usual: "I know my argument doesn't really hold water, but I like it anyway." :-) I can identify that feeling quite easily, because it's one to which I can personally relate, as the psychological people like to phrase things.
 
8:08 PM
@rightføld Who gives a crap how that gets implemented.
Haskell has side effects.
 
user1804599
No, that's bullshit.
 
> (Of course they do IO but I assume you meant something slightly more meaningful)
 
The evaluation of main = putStr "ok" produces the side effect of a string ok to be printed to my terminal. That's a side effect.
 
user1804599
Haskell cannot have side-effects, since having side-effects implies being impure, while Haskell is pure.
 
user1804599
@Sofffia No, that's bullshit.
 
8:10 PM
Is it done during the evaluation, after, in another dimension, doesn't matter. It produces a visible side effect.
 
user1804599
The evaluation of main produces an I/O action, nothing more.
 
@rightføld That how you keep a discussion open. By keep stating that something it's bullshit.
 
user1804599
Now what the evaluator of main does with that I/O action is its own damn business, but not Haskell's.
 
@rightføld I don't have any effect on the environment, it's my janitor who does, he's the one bringing the trash to the curb.
 
@Borgleader Yeah neither did I. ^_^ Cult reference, though.
 
user1804599
8:10 PM
@Sofffia Yes, and then I explain the same thing as I did ten times before.
 
@rightføld What do you mean "Haskell is pure"?
 
user1804599
Okay, let me explain it with a C++ code example that does the same thing.
 
You mean that Haskell is purely functional?
That every function must return something deterministic?
 
user1804599
It means that all expressions are referentially transparent.
 
What does it mean?
 
Xeo
8:15 PM
You can write a Haskell programm as one giant expression, and the meaning doesn't change
 
user1804599
It means that all expressions have no side-effects, and, if they halt, they always result in the same value.
 
user1804599
And if they don't halt, they never halt.
 
user1804599
But halting sucks.
 
user1804599
HALT! HAMMERZEIT!
 
So you are going to claim that the result of x <- getLine is deterministic because IO a is always the same value?
Is that it?
 
user1804599
8:17 PM
Yes.
 
You are being pedantic over that?
Fuck you.
 
user1804599
@Sofffia Indeed.
 
user1804599
Now in Styx expressions are not necessarily referentially transparent, and the need for a comma-operator-like construct arises.
 
@Sofffia Your initiation is now complete. Welcome to Lounge<Pedantry>
 
@rightføld That is terrible.
 
8:19 PM
No, pedantry in the lounge usually serves a purpose. This one is just to piss me off.
 
user1804599
@Puppy Why?
 
Ell
I don't think being pedantic about this is useless
I think you must understand "has no side effects"
 
Even haskell.org defines >> has being basically the same thing as ; in imperative languages.
 
user1804599
The largest problems with the comma operator in C++ are its syntax and its overloadability, but Styx doesn't suffer from those problems.
 
@Xeo But also note that program verifiers for imperative languages (e.g., Ada) have taken roughly that approach for years. It does mean the verifier uses a huge amount of memory (has to store the relevant state at every invocation) but is ultimately a relatively simple problem (just on a very large scale).
 
user1804599
8:21 PM
And expressions are way better than statements because they are actually composable.
 
user1804599
@Sofffia Where does it say that? inb4 in the noob tutorial which is too afraid to talk about abstract concepts towards noobs
 
@Xeo Most start, however, by "flattening" trees of function calls (and such) that are themselves free of side-effects (which, tends to be a large percentage of decently written code, even in languages that allow mutations/side effects/state).
 
20 mins ago, by Sofffia
> Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in imperative languages.
Hackage documentation of >>
 
user1804599
Actions, not expressions.
 
@rightføld Statements are composable too.
 
8:23 PM
Yes, "discarding any value produced by the first".
 
user1804599
of the first [action]
 
user1804599
An action is not the same thing as an expression.
 
It's irrelevant.
 
user1804599
It's very relevant.
 
The execution of an Haskell program produces a side effect. Is it the evaluation of an action? Nobody cares.
 
8:24 PM
the difference between having statements and semicolons, and introducing the comma operator for side effects, is that the first is readable and familiar and the second is horrendously obscure and totally unreadable.
 
user1804599
putStr "ok", for example, is an expression that when evaluated yields an action.
 
Ell
@Sofffia not in the haskell world
 
@rightføld Yes.
 
user1804599
@Puppy syntax is completely irrelevant.
 
user1804599
8:25 PM
You can invent whatever syntax you want for said operator.
 
user1804599
And my syntax happens to be { expr; expr; … }. (With one special case and that is that variables can be introduced as well.)
 
putStr "ok" is evaluated when the result of the program is needed.
Which happens when main is evaluated.
 
user1804599
Indeed.
 
How main is evaluated is irrelevant. The fact is that when the program finishes "being evaluated", an effect have been produced.
 
user1804599
And that results in an action.
 
8:26 PM
No, it's the final I/O operation.
 
user1804599
@Sofffia No, only an action has been produced.
 
user1804599
The evaluator of main decides what it wants to do with that action.
 
Actions are produces and then evaluated.
All this happens before the program finishes executing and the control is returned to the OS.
 
user1804599
main in Haskell is not the same thing as main in C++.
 
user1804599
GHC happens to produce main that is called by the OS (which is the same thing as main in C++), and that main evaluates Haskell main and does something with the produced action.
 
user1804599
8:29 PM
It's that main that GHC invented that does the I/O, not the main you wrote in the Main module.
 
zoidberg is almost zoidberg again!
 
Yes, rightfold. I've already understood your point.
It's just so close minded that I've almost turned off my brain to follow it.
 
user1804599
Well, time to take a shower, then.
 
user1804599
 
"The Haskell standard says an action is produced. Not I/O."
Fuck you.
 
user1804599
8:31 PM
Exactly.
 
Ell
Right
actions are produced by haskell
then the thing immediately above haskell evaluates the action ( I think?)
 
It's almost as stupid as arguing over the fact that the standard calls member functions "member function" instead of "methods".
 
Ell
@Sofffia I don't think so
 
user1804599
No, because member functions and methods are the same thing.
 
user1804599
8:32 PM
But actions and expressions are not the same thing.
 
> almost
Also I like that you have come back to some zoidberg avatar.
Much better than before.
 
Hi guys, nice to see you again.
Wow, what's up with the tone in here?
 
@CaptainGiraffe What tone? Does your Lounge<> chat produce music?
 
8:52 PM
@VáclavZeman Mine plays the beautiful music of Eru Ilúvatar (with Darkness playing the part of Melkor).
 
Ell
> error: implicit instantiation of undefined template: std::function<bool ((lambda at main.cpp:94:18)::*)(int, double) const>
dang
 
So epic
 
user1804599
@Ell a pointer to a member function type is not a function type.
 
user1804599
Sig in std::function<Sig> must be a function type.
 
Ell
@rightføld it aint a pointer to a member function
but yeah, I understand the error
I was just hoping it wouldn't happen :P
 
8:56 PM
@CaptainGiraffe shut it
@Ell How is it not?
 
@LightnessRacesinOrbit The tone?
 
@Loopunroller bzzzzzzzzzzzzzzzzt
 
@LightnessRacesinOrbit I don't even
Just what
 
Ell
@LightnessRacesinOrbit because it's a lambda
I guess it is then actually on second thoughts
 
@Ell What do you think a lambda is? Did you even read the error message? Bloody ell.
How did you manage this, anyway?
std::function<[](int, double) -> bool { return true; }> f; or some shit?
 
8:59 PM
@LightnessRacesinOrbit lol
Nobody writes haha in chats anymore, that's not professional
 
auto f = [](int, double) -> bool { return true; };
std::function<&f> asiudhfasdaf;
perhaps
 
@LightnessRacesinOrbit That's just bullshit.
 

« first day (1458 days earlier)      last day (3484 days later) »