« first day (388 days earlier)      last day (4551 days later) » 

12:01 AM
damn, I'm a genius
Error: Encountered unexpected token after [identifier], expected '{'. Found "{"
 
0
Q: Underlying meaning of bizzare tag

XaadeWhat is the meaning of always-waffle-in-iceland. Is there some joke meaning. Like this is the lame joke tag? Otherwise, should I report the tags as nonconstructive???

 
lolwot
 
It's one of the meta memes.
> Trivial answer converted to comment
WTF?
 
@DeadMG ouch
 
12:15 AM
agreed
 
i just +1'd your comment
 
Well my brain isn't working good enough to do start debugging and following some silly flow
So it's time for sleep
Night night guys
 
nn
argh, dumbass parser can't parse more than one namespace :(
 
NAMESPACES := NAMESPACE*?
 
I didn't generate it, I've written it by hand
 
12:18 AM
Well, do the equivalent?
 
I am
for some reason, it seems to be just not noticing the other namespace
it's probably annoyed with me because I called the second namespace "your_mother"
 
lol
please namespace your_mother {}
 
ok
it seems to have parsed them as nested namespaces when they aren't
probably because I forgot to tell it to stop at the appropriate time
ok
now it figured out that they're not nested, so it seems to be ignoring the second namespace
this is really kind of tedious
 
Why do you think there are generators?
 
find me one that doesn't suck and I'll use it
 
12:29 AM
YACC sucks, and the ANTLR C++ runtime sucks. I don't know another for C++ :(
 
yeah- bison sucks too
 
bison is like advanced yacc or something.
 
yeah, it's based on yacc
I nearly had a finished parser based on bison
but I had to stop because my function definition grammar, which was totally LALR(1), would be way too much to implement that way
just because bison is too stupid to know the difference between type_expression identifier(stuff) and type_expression identifier(some_kinda_similar_stuff)
unless I hold it's hand, anyway
 
I never really understood how you could possibly use yacc's error handling for decent errors.
 
me neither
but my parser most definitely propagates the necessary information, so it's all good
 
12:36 AM
@DeadMG - how easy is it to write a frontend for clang?
that might be quite a nice way of doing it
 
there's a reason EDG sell their C++ frontend for tens or hundreds of thousands of dollars
 
I thought you were trying to stay away from the pitfalls of the C++ grammar.
 
that was the other thing I was about to bring up
that I am absolutely not going to do anything as dumb as C++
my grammar was LALR(1)
 
"was"?
Are you saying it isn't anymore?
 
still is
it's just not fun to use a parser generator to parse it because they're not exactly set up for complex LALR(1) grammars
DRY violations up the wazoo
I nearly wrote a program to generate the grammar, lol
 
12:40 AM
That's why I like Haskell for this kind of thing. I can write stuff that looks like EBNF and reuse things.
 
eh
my custom parser will be significantly faster, most likely
 
When it works.
:P
 
lol
yeah
right now, it can parse namespaces and nested namespaces at an Incredible Pace!™
 
You mean this? namespaceDef = namespace *> identifier *> (between lcurly rcurly (many namespaceDef)) :P
 
lol
something like that
I could have something like that if I wanted to use Spirit, you know
 
12:45 AM
Why didn't you use Spirit?
 
I had a shitbunch of problems with LL grammars in ANTLR
 
Never saw it, but I expect it's chock full of weird uses of operator overloads.
 
I found LALR much easier to write in
my experience of LL grammars was that my natural inclinations of how to write it simply didn't match up with how the generator wanted it expressed
 
Parsing of expressions is weird, I guess?
 
yeah
my idea of what expressions should look like is like
expr := expr * expr | expr - expr | identifier | literal;
but that's not what the parser wants to see for expressions
 
12:50 AM
I assume you're ignoring precedence on purpose.
 
yeah
also, I expect that LL would suffer on my function definition grammar just like LALR did
 
With Parsec they look like expr = lowerPrecExpr `chainl` op. Reuse is awesome.
There's chainr for right-associativity too.
 
that's pretty convenient
but again, that stuff was all solved, it was function definitions I had trouble with
plus, somehow I feel more secure with actual, readable code
 
I don't understand the problem in function definitions (but then I don't know how far from C you strayed on that.)
 
instead of that absolute mess of LALR code
ah
I didn't go very far- that was the problem
type_expression identifier( [type_expression] identifier [ (:= default)]* )
the problem is, guess what variable definitions look like?
with explicit arguments to their constructor
 
12:56 AM
Oh, MVP?
 
type_expression identifier( identifier [:= default] )
not exactly
I don't have declarations, unless they're virtual, which is fine
the problem is that you can only disambiguate at the end, when you find either ; or {
or, if you find type_expression in the argument list
 
Yeah, that doesn't fly well with an LL grammar.
 
yeah
it's LALR(1) because you can do stuff like
ambiguous_argument := common_stuff;
function_def_argument = ambiguous_argument | uncommon_stuff;
function_def_or_variable_def := ... ambiguous_argument* function_def_argument*
that is, you can get it to tell them apart, the problem is that you basically have to duplicate huge parts of the grammar
or my solution will probably be to just look ahead infinitely at that point
it would be much simpler
 
looked weird to me
	/* Figure out how many bytes the result will require */
	if (ch < (UTF32)0x80) {	     bytesToWrite = 1;
	} else if (ch < (UTF32)0x800) {     bytesToWrite = 2;
	} else if (ch < (UTF32)0x10000) {   bytesToWrite = 3;
	} else if (ch < (UTF32)0x110000) {  bytesToWrite = 4;
	} else {			    bytesToWrite = 3;
					    ch = UNI_REPLACEMENT_CHAR;
	}
 
What's that? UTF8 decoding or something?
 
1:03 AM
yeah
and it's not right, because those literals are wrong
I'm pretty sure, anyway
no wait, I think I might be confused with UTF8 -> UTF32
 
I think they're right.
 
man
a language which offers as much power as mine needs a seriously flexible grammar
 
lol
What does that mean, btw?
 
it means
where the C grammar requires hardcoded things, like
type identifier ... for a function
and mine permits expressions, like expression identifier ...
then it introduces a lot more potential for ambiguity
 
Introduce disambiguators!
typename and template!
 
1:07 AM
put simply
no
 
Yeah, I was joking.
 
^^
I could have had function and var keywords, and at one point, I did
but I ditched them because, well, I think that they should be unnecessary
 
What do you use to declare variables with inferred types?
auto?
 
identifier := expression
auto is implied
 
And assignment is not :=?
 
1:09 AM
nope
it's = just like in C++
:= is used only for initializing, and other special stuff like default arguments, etc
 
That's what Go does.
 
really?
how strange
 
Yes. x := 4 declares a variable.
 
win
 
But you can also do x int = 4.
 
1:10 AM
could somebody check whether recent version of g++ has C++11 header <codecvt>? e.g. just compile #include <codecvt>
4.4.1 does not :-(
 
Gimme a sec, I have 4.7.
 
in WideC you can also choose to do int x := 4;
after all, as far as I know, you might want to do GetDatabase("mah_database").GetTable("mah_table").GetTypeOfColumn("mah_column") x = 4;
 
a.cpp:1:19: fatal error: codecvt: No such file or directory
compilation terminated.
:(
 
ouch. then i must implement the conversion, just to support g++
i found implementations from Unicode consortium at gears.googlecode.com/svn/trunk/third_party/convert_utf
 
Neat.
@DeadMG That seems really cool. Usual solutions involve lots of generated code, or manual placement of attributes on languages that let you inspect those at runtime (like C#, and I think Java too).
 
1:17 AM
it is really cool
unfortunately, it also makes the language, eh, difficult to parse :P
 
type the_type_of_the_thing = GetDatabase("mah_database").GetTable("mah_table").GetTypeOfColumn("mah_column");
the_type_of_the_thing x = 4;
Though I'd write it like this.
 
if you want the type back, you can always just decltype it
 
Or whatever type aliasing syntax you have.
 
it's pretty much that
except I changed type to TypeReference
but hey
 
TypeReference type = decltype(type);
:P
 
1:19 AM
heh
 
(Is that valid?)
 
yes
 
type is in scope in its initialization?
 
yes
 
So you can write a recursive lambda like fact := λn. n * fact(n-1);? (adjust your lambda syntax) Neat.
Btw, that lambda syntax would be cool :)
 
1:21 AM
C++ only doesn't allow that because the type has to be deduced
 
But that's not C++!
 
C++ only doesn't allow recursive lambdas
it's forever been known that you can do shit like int x = x; if you want to
it's the same rule as being allowed to use this in the initializer list
 
Ouch, I didn't know that. (Not that I gain much by knowing it)
 
but in WideC, if you equate it to a literal lambda, then the type of fact can be FunctionReference
regardless of the signature of the lambda
so you don't have to know what the lambda body is to know the type of fact
 
Are lambdas monomorphic (i.e. lousy) like C++?
 
1:24 AM
nope
I'm still working on the details, exactly, of how variadic templates are going to work
but regular inference is just fine
in fact, I can use my language rules to do some much sexier type inference than you can find in C++
or indeed, any kind of inference
 
Type inference on pretty much every language I used besides Haskell has always been nil, or desperately asking for more.
 
if you had massive balls, you could do something like
float f; 4 = sqrt(f);
 
What does that do?
 
deduces f
very Prolog, in a way
 
Ow.
Could write something weird like the Haskell fixed-point finder? fix f = let x = f x in x? (Given f, it finds x such that x = f(x))
 
1:28 AM
for any f? that's impossible
what if f is std::vector? There is no type T such that T = std::vector<T>
 
It's possible for all functions that take a function as argument.
f is supposed to be a function.
 
std::vector is a function.
 
even in C++, it's effectively a function
just written in a funny way
in WideC it's written more naturally
 
Anyway, it only works reliably with functions that take function arguments.
 
1:30 AM
type vector(type t) { return type { ... }; }
I still don't even see why you'd want to know
but I don't think I'd have anything like that
 
Because it's cool!
(In Haskell, it's defined exactly like I posted)
It's used to encapsulate recursion.
You can build pretty much every recursive construct on top of it.
 
as if I have a problem building recursive functions in C++?
 
The point is to encapsulate the recursion pattern, so that it can be reused.
 
well, it can't be reused
something like factorial is direct tail recursion, something like BST is binary recursion, and something like iteration would be infinite, potentially, recursion
I also don't see how it would help
recursion isn't really something that I ever labelled as "re-usable", that's like trying to make having integers re-usable
it's a basic language feature and doesn't require special help to be useful or usable
 
For example, you can write a memoize function that does memoization given a recursive function.
 
1:36 AM
anyway, I doubt that I'd have anything like that
no, you can't
what if the recursive function takes an argument that is not hashable or comparable?
how are you going to associate the argument with the result?
unless you want to do linear search, I guess
and do I need concurrency-safe memoization or not?
 
You can write a concurrent_memoize function for that.
 
and how does fix even tie in to that?
plus, I don't need fix to write a function that can memoize other recursive functions
if they're known at compile-time
 
I'm not saying you need it. fix encapsulates the most basic form of recursion.
 
but how?
how does fix allow you to do ... well, anything, at all?
 
1:53 AM
Here's a silly example: ideone.com/jbH7H.
 
I can't read Haskell, remember?
 
I know you can do the same in JavaScript, but I don't know enough JavaScript :(
 
nor do I
what does it do, and how?
 
The fib function is the normal Fibonacci thing, because it uses "basic recursion" (the fix thing, which is better called rec). The fib2 if Fibonacci with the result of every recursive invocation doubled (I think, it's getting late), because it uses the "weird recursion".
If you replace the doubling part with something that actually memoizes, you get something actually useful.
 
right
I'm not really seeing how fix is used in all of this
 
2:03 AM
Sorry, fix is rec in the example.
 
yeah, same principle
seems to me like the example could be exactly re-written like
int fact(int target, std::function<void(int)> f = fact) { if (target == 1) return 1; else return target * f(target - 1); }
fact(5); // normal case
fact(5, [](int target) { return fact(target) * 2; }); // weird case
 
Of course. I'm not saying it's the only way to do that (or the best).
34 mins ago, by R. Martinho Fernandes
Because it's cool!
 
yeah
but how on earth does a fixed-point come into this?
seems to me like I just re-wrote the exact same thing without requiring one at all
 
I could ask you to write it in a way that memoizes, but that would not be fair because I didn't want to do it either.
But [](int target) {if(cache.has(target) return target; else return cache.put(target, fact(target)); } does not work very well, because it doesn't use memoized intermediate results.
For that you need to pass the lambda to itself.
(Can you use this in a C++ lambda to refer to itself?)
 
@RMartinhoFernandes No. Either it refers to the enclosing this if in a member, or it's an error. So no recursive lambdas.
 
2:15 AM
@RMartinhoFernandes What do you mean, doesn't use memoized intermediate results?
I don't see how that lambda is not exactly memoizing, except for the error you made if target was already in cache
 
@DeadMG If it doesn't find a result it calls fact(target), not fact(target, memoizing_lambda).
 
ok
you can still do that without much hassle
std::function<void(int)> memoizing_lambda;
memoizing_lambda = ...;
in which case, you most certainly can call memoizing_lambda inside the body of the lambda assigned to memoizing_lambda
 
Another difference is that you can't store [](int target) { return fact(target) * 2; } and reuse it for a weird Fibonacci generator. It only works for that one fact. weirdRec is not tied to any particular function, it's just the recursion pattern.
 
that can be solved too, if you really want to, simply by creating another lambda (...) and passing in the function to be called
 
That gets you close to fix.
 
2:20 AM
no, it doesn't get you anywhere near
there is absolutely no need for fixed-points
 
@DeadMG The fixed-point of that lambda is the original function without memoization.
 
uh, no
you said a fixed point was a value x such that f(x) = x
 
Can you write the lambda?
 
none of these functions have any such points
which lambda?
 
3 mins ago, by DeadMG
that can be solved too, if you really want to, simply by creating another lambda (...) and passing in the function to be called
This one.
 
2:23 AM
probably
give me a minute
just a quick note
I don't actually know if int fact(int target, std::function<void(int)> f = fact) is even remotely legal C++
but I'm pretty sure that can be arranged anyway
 
Probably not. I don't think the function name is in scope in the parameter list. But we can overlook that :)
 
well, you can produce the same effect, if you're desperate
but I'll skip the boiler-plate
hmm, I keep getting my shiz mixed up
you'd have to use a template, not a std::function
and function objects
else the signatures are infinitely recursive, I believe
 
Oh, cool, someone wrote fix in C++.
11
A: Fixed point combinators in C++

witkampHere is the same code converted into boost::bind notice the y-combinator and it's application site in the main function. I hope this helps. #include <boost/function.hpp> #include <boost/bind.hpp> #include <iostream> // Y-combinator compatible factorial int fact(boost::function...

 
told you it could be done
 
The type system of C/C++ does not allow you to write a prototype for a function that accepts a pointer/reference to that same function type, indeed.
So additional layer of indirection and all that.
 
2:35 AM
@DeadMG That fact in the answer is what you were trying to write?
 
no, I merely implied that it could be done
I'm trying to write something a tad more, uh, flexible
 
Right, but that y function is fix.
 
right, ok
 
Obviously it looks different in C++, because x = f x in C++ isn't magical.
 
well, I probably can't see it because he didn't use it to apply any effect
so the fact that I can't actually see how anyone would use it to write a doubler or a memoizer is, well, not surprising
 
2:38 AM
Anyway, it's not terribly useful (not even in Haskell, I don't remember having ever used fìx other than when toying with it).
Using λ for lambdas would be awesome, btw :)
 
my keyboard, and pretty much nobody's keyboard, has that character
 
You program with charmap open!
I think :abbr lambda λ would work in vim.
goes off to try it out
Yay!
 
lol
not going to happen
 
damn
I'm close, but for some reason, I got a way too high answer
 
2:44 AM
What now?
 
the answer I should get is 240, but I get 3840
 
the second output is the right answer
no, wait, the first output is the right answer, I just did it on my calculator
5! * 2^5 = 3840
for some reason, doubled_fact is returning just 5! * 2
oh, whoops, my mistake
 
2:48 AM
    return 2 * target * doubled_fact(target - 1);
 
the problem is, you really can't do this at all, because of the signatures and templates problem
 
That guy on the question I posted did with boost::bind.
 
well, actually, I guess you could, but it would be a tad of a mess
yeah, bind qualifies as a "tad of a mess"
besides, I'll believe that he did it when I see it doubling my fact
 
Lemme see if GCC 4.5 has std::bind.
 
I think it should have it in TR1
 
2:51 AM
ideone should install boost.
Ugh, I have no idea where to place the doubling part in that code.
 
I've nearly got it
slight mess, atm, but nearly got it
 
> prog.cpp:29:71: error: return-statement with a value, in function returning 'void'
I don't get this one.
There's no void anywhere in sight.
 
implied void in lambda?
 
Yes, making the return type explicit worked, but shouldn't it deduce it when there's only a return statement in the body?
(It could just be GCC going nuts because of other errors.)
Woo, compiles. Wrong result though: ideone.com/dVYZ6
 

« first day (388 days earlier)      last day (4551 days later) »