« first day (268 days earlier)      last day (4682 days later) » 

3:00 PM
yeah
I have a "blank" project that I usually use for trying to use code posted on SO or other random, short musings
 
Xeo
Yeah
 
I use ideone for that.
Or LinqPad if it's .NET code.
 
Xeo
but my blargh project got an "unused.h" header where I copy paste the content of my main.cpp after I'm done playing around
At the moment, I think it amounts to 1.2k LoC
+ some 20 headers
With random TMP stuff
 
So, you write throw-away code, that you don't actually throw away?
 
Xeo
Yeah
I like lookin at it again
like some random playing with trailing-return-sfinae
on which MSVC currently chokes tho
 
3:07 PM
@DeadMG You're striving for a simple grammar, or you don't care if it's as complex as C++'s?
 
I'm definitely aiming for something not context sensitive
beyond that, I'm not too bothered
not completely sure how to make my function definition grammar
the grammar for them is a little strange, now I come to think of it
having to allow both things like main(int) and main(argc) in the same grammar
 
int will be a keyword or something, right?
 
actually, I have been thinking of getting rid of them
just having like, a std::integer(bit-size)
but even if I did, it would still have to be main(type) for unused arguments and main(identifier) for automatically type deduced arguments
 
You'll have to solve that up in semantic analysis.
 
nah
the first would be a type-definition, and the second is an identifier
 
3:15 PM
I don't see how you could always disambiguate in the parser.
 
you can't
at least, I don't see how you could do that context-freely
thing is that even if it's a type-definition, they have to be expressions now too
you'd have to look ahead until you could for certain find it used as a type in the few remaining unambiguous places
well
you could guarantee it if you had an expression, because those obviously are distinct from identifiers
 
But an isolated identifier is an expression.
argc is an expression.
 
yes
but expressions are not identifiers
if you had main(std::integer(32)), then that has to be a type when you're defining the function and not calling it
also, I could just forbid giving unused arguments no name
 
But that could be a function calling too, couldn't it?
 
that would quick-like clear it up
sure
but not with { code } after it
I don't have any syntax that would look like identifier ( expressions ) { something } except function definition
 
3:22 PM
Hmm, you need some lookahead for that to work.
 
a little look-ahead is nothing deadly
 
And... if you get rid of keywords, if(foo) { stuff } would match that.
 
wondering if I can grammatically ditch the semicolon
oh, I haven't cut keywords in general
just possibly the integral line and maybe the float line
 
@DeadMG Certainly possible. It's been done before.
@DeadMG No keyword types sounds good.
 
I still have most of the rest, like the cast keywords, class, namespace, type
well, if you want to use int, there's nothing stopping you doing static const int = std::integer(32); or whatever floats your boat
 
3:24 PM
The problem with ditching the semicolon is that it probably ends up limiting coding style. That may or may not be something you want to have.
 
especially where integral literals are concerned
it certainly limits the need to have explicit integral type keywords when you have automatic type deduction and integral literals
now, the question
do I need to grammatically define which arguments are in which pass, or do I just take one huge block of arguments and let the compiler magic it?
ahem
try-to-infer-it
 
Sounds complicated.
If feasible.
 
well
right now, I already was going to have to infer what to do in what pass of compilation
 
You're planning to infer return types as well?
 
yep
and argument types, and local and member variable types, if possible
 
3:28 PM
Like, hypothetically, in C++ template <class T> T get(); int x = get();
 
oh
don't know
that's a semantic question, not a grammatical one, I think
 
Yes, the grammar is irrelevant.
 
I was going to introduce a few "magic" type arguments
like "derived-type"
so you could enforce that the type you got was a type deriving from you, if you wanted
 
Please don't allow - in identifiers.
It's madness.
 
no
I haven't actually defined identifier, but it's going to handily ban anything I might dislike
hmmm
the EBNF of "Anything that isn't X"? :P
literals, I've forgotten literals
except type literals
 
3:33 PM
Don't know. I only worked with the unextended BNF stuff.
And several parser specific implementations.
I like the usual [_\w][_\w\d]* for identifiers.
 
oh, I can express "Anything else" in C++
man, I hate regular expressions
especially since UTF-16 is what I'm working in, and I want to allow any Unicode character in identifiers
 
That's why I used \w and \d. A Unicode-aware regex engine will accept those.
 
except the ones I define as reserved of course
I'd rather not use a regular expression if at all possible
I despise them greatly
 
Well, regexes really shine for doing lexical analysis.
 
hmmm
can I use regexes to say "Anything that doesn't start with a number or use any of my reserved characters"?
 
3:36 PM
Yes.
 
the regex classes I did didn't cover them in that much depth
 
[^\dxyz][^xyz]* would match everything that doesn't start with a number, and has no x, y, or z.
But for identifiers it's better to use whitelisting instead of blacklisting.
 
no
 
You have lots of Unicode crazy stuff to forbid.
Like spaces that are not spaces.
And newlines that are not newlines.
 
well
that's your own dumb fault for using them
I absolutely want to allow Mandarin or Korean identifiers, for example
 
3:38 PM
The word-character-class (\w) should cover those.
 
is that still covered in \w?
ok
 
As almost everything depends on the engine. But most do.
Haven't looked much at the C++11 regexes, so I can't vouch for those.
 
I think I have those in Visual Studio
hey
do you remember that discussion I had about automatic-size numerical literals?
now I don't have to write code to parse "LL" suffixes & stuff
 
Gosh, I hate those.
 
not sure how to handle floats with them, though
 
3:44 PM
Hmmm, I wouldn't like having to write 1.0000000000000000000000000000000 just so I could have a double instead of a single.
 
right
I think I might be done
oh crap, I forgot references
and pointers
not that I'm sure that I actually want pointers in my language
but they're probably ultimately necessary
 
If you're ditching them, you need something else to give their power.
 
Xeo
If you only want references and value types, please, don't go the C# way - make them different syntactically
 
I was going to keep the existing reference syntax
and semantics
just not have pointers
 
But the existing reference semantics do not replace pointers.
 
Xeo
3:46 PM
But why drop them? Aliasing?
 
unfortunately, that's true
 
Xeo
Or because >50% of the programmer just don't get them?
 
yes, it would make my life easier if aliasing didn't exist
until I need an alias, anyway
 
You mentioned a "memory" type some days ago.
That could do for implementing something like vector.
 
yes
good shout that man, I forgot that, it's a key-word
oh no
that's not about replacing pointers- you'd still have to have a memory*
it's about making a char* point to a character
 
3:49 PM
Damn pointers.
 
the fact is that in some cases you need to deal with raw memory, and there's nothing more explicit in that than, well, having a type called memory
 
But pointers.
 
oh yes, pointers
I cut like, every pointer conversion
even inheritance
 
How do you make things like placement new work without pointers?
 
only references now
placement new takes a pointer to memory
actually, I cut placement new as it is, but it's functionality still exists
 
3:51 PM
How does it work?
 
well, you use the constructor now
conceptually, a constructor is a free function that takes memory and returns a pointer to a valid object
and that's exactly what they are now
of course, in most scenarios, then the memory argument is implicitly dealt with
 
Hmm, that looks similar to Go's constructors.
Except for the memory argument.
 
and they have a funny syntax, tis true
well, the thing is, I junked normal new, so if I changed placement new then I could lose a keyword
oh, man, exceptions, I totally missed exceptions
 
How do you do dynamic allocation?
 
library
now that we have perfect forwarding, I use library calls for all dynamic allocs
 
3:54 PM
Oh, you changed new from a keyword to a function. Ok.
 
basically
 
Hah, operator precedence fail!
:P
 
what operator precedence? it's not an operator anymore
 
I'm talking about * vs +.
 
what do you mean? I haven't written any precedences
 
3:57 PM
That's what I'm talking about.
 
hey
I could make empty catch blocks grammatically illegal
 
The grammar you posted has + and * (and others) under the same precedence. The easiest way to deal with that is in the grammar.
@DeadMG Sounds like a good idea.
But I'd like a way to make ignoring an exception explicit.
 
ok
I don't have statements
are those important?
everything is just an expression
 
Someone explain to me what is the xor?
 
Where's return, for example?
 
4:01 PM
fuck
 
And if, while...
 
yeah
I miss a lot of that stuff
 
0
Q: What are XAND and XOR

Arlen BeilerWhat are XAND and XOR? Also is there an XNot

 
hmmm
should I ban if statements with just one expression not requiring braces?
 
I'd vote for that.
Go does that, btw.
I'll be afk for a while now. Brb.
 
4:02 PM
bb
 
@DeadMG If you're asking: "Should I mandate braces, even if they only enclose one statement?", then the answer is definitely no. It's just a crappy, misconceived idea. IMO, those who use it are basically cargo-cult programmers, going through the motions without understanding what they're doing.
 
I, for one, find grammars that allow you to skip braces in some cases just plainly inconsistent.
Make rules, not exceptions.
Or something.
 
@CatPlusPlus There's no exception here at all. The subject of an if statement, for example, is a single statement. The BNF for an if statement in C++, for example is:
selection-statement:
if ( condition ) statement
if ( condition ) statement else statement
 
4:18 PM
Hey, the book Effective C++ it's good?
 
What you'd be doing is changing the controlled statement to a compound-statement instead of a statement. You could do that, but you could not be addressing any inconsistency in so doing.
@BrunoAlano Extremely. Virtually every C++ programmer needs it (though as a second book, not first).
 
@JerryCoffin My first book it's: C++ Begginers Guide by Herb Schildt, but I don't readed the Templates section, I go to Effective C++?
*C++ Beginners Guide
 
@BrunoAlano In the case of anything by Schildt as the first book, you want to move Effective C++ to third place -- after replacing the Schildt book with something decent.
 
for me, mandating braces isn't about being cargo cult or anything like that
I just don't see why it should exist
if statements with no braces, that is
 
Because they're simpler to write?
 
4:25 PM
@DeadMG Because an if statement controls a single statement. That can be a simple statement or a compound statement as needed. The real question is why you'd mandate that it be a compound statement.
 
I actually appear to just not have statements
and everything is just expressions
 
You probably want to make either all or some expressions a statement.
Like function calls and assignment for example.
Otherwise your grammar will get clunky: 'if' expression (statement | expression).
 
what purpose do statements even serve?
 
Are you making if and while expressions?
 
ok
 
4:28 PM
(I can understand an if expression, it's just like the conditional operator, but while is weird)
 
now I see why you need statements
 
You don't, really.
Lisp has no statements whatsoever.
 
@MartinhoFernandes Yes -- actually, if as an expression (a la Algol) can eliminate the conditional operator, and make a lot of code more readable. x = if a then b else c; is generally a lot easier to read than x=a?b:c;.
 
I don't have the ternary operator
decided to ditch that a long time ago
 
@JerryCoffin I agree, it's way more readable. Haskell does that as well.
 
4:31 PM
I like Python's <true> if expression else <false>.
 
@CatPlusPlus In that case, you might want to look at Forth.
 
I tried to get into Factor, but I'm too lazy to switch paradigms.
 
@MartinhoFernandes Yeah -- Haskell does a lot of things right. Unfortunately, I think the emphasis on functional purity is misplaced -- there are places/times/situations in which it works well, but others where it's just plain stupid (and the difficulty people have with monads, for one example, demonstrates that quite nicely, IMO).
 
functional programming is great, but it's sure not something I'd want to structure my whole program around
 
I like monads.
 
4:36 PM
I like Haskell's type system.
 
Type classes are awesome.
Type quantifiers, too.
 
Yes, they are.
 
I've seen the argument (similarly made for C++) that this is what makes OCaml great: "natural" FP, but the ability to drop to imperative programming when it's more convenient.
 
@MartinhoFernandes Like them or not, the difficulty a lot of people have with them seems impossible to deny. They're kind of a neat solution to difficult problem, but when you get down to it, it's a problem of their own making that would be better avoided than solved.
 
There are mixed functional-imperative languages, OCaml, F#, but TBH, if I'm switching to a functional language, then I don't want to stick to the imperative stuff, I want to use the more awesome style.
 
4:38 PM
@JerryCoffin there's still a tradeoff involved though, in that picking a more "natural" solution would break functional purity, which would make it harder (for the compiler and the programmer) to reason about many aspects of the code
which isn't to say I disagree with you. My preferred functional language isn't pure, and doesn't have monads built in
 
ok
I'm missing a few things, I know, but hopefully so far that's correct
 
Stop dissing my dear monads!
 
Steam Summer Camp ends in 20 minutes. Maybe I'll win something (yeah, right).
 
@CatPlusPlus I think there are different degreese of "impurity" too. Some languages, like F#, seem to make it very easy to stick in an imperative mindset, which might make the transition to FP needlessly hard. Other languages have a few rarely-used "back doors" allowing impure code, but without really influencing the core language much at all.
 
@jalf Yup, no question there's a tradeoff. I think the loss from monads is usually greater than the gain though.
 
4:40 PM
@DeadMG Return is an expression? Why?
 
not entirely sure :P
it probably belongs as a statement now
 
Haskell's do notation + monads is like overloading ; Seems awesome, and scary at the same time.
 
Return is an expression in Haskell, too. :P
Overloading your brain, that is.
 
I'm not actually sure that this is working out, maybe I just suck at defining grammars
 
I would feed that to a parser generator.
 
4:43 PM
but I keep getting the nasty feeling that I'm missing a few rules, and not just while, for, and do-while
 
To weed out ambiguities and unused branches, and missing branches and stuff.
 
You can do throw throw throw throw throw throw something; by the looks of it.
 
That's for throwing very far.
Like across the network, for example.
 
lol
 
It's just making sure.
 
4:45 PM
@DeadMG I'd eliminate the else-if-statement production. It's unnecessary and probably ambiguous.
 
You need to use the same number of nested try-catches to catch that.
 
@Jerry: How would you write it?
 
try try try try try try {
    throw throw throw throw throw throw 42;
} catch catch catch catch catch catch (int) {

}
 
@DeadMG You need to add stuff to the statement production.
Like the if-statements and stuff.
 
... else { if (cond) is not the same as else if(cond)
 
4:46 PM
If you do that, you don't need special casing for else-if.
 
yeah, I got that, and I added the return-statement
 
And if something inside try uses too few throws, you call std::blow_up.
 
@DeadMG Probably pretty much like C does: an if, and an else. If they want an else if, that's an entirely separate if statement in the else leg of the first if statement.
 
And if there isn't enough trys, compiler stops with "try harder" diagnostic.
 
sure, but that would syntactically allow things like
if () else {} else if () {}
 
4:48 PM
No, because an if cannot have more than one else.
 
Make else if an elseif or elif or something.
 
actually
 
Right now your assignment expression also allows things like 2+2=17. You just about need to separate expressions into some analog of rvalues and lvalues.
 
I guess it wouldn't, because the else wouldn't have a trail on it
rvalues and lvalues are semantic, not grammar
my grammar allows 2+2 = 17, yes, but I sure don't semantically allow it
 
@DeadMG They can be made part of the grammar, and doing so generally makes things simpler overall, and (particularly) makes it a lot easier to diagnose problems.
 
4:50 PM
Yeah, everyone knows 2 + 2 = 8.
 
What about (a? b : c) = 42 and (a? 2 : 3) = 42. How can the grammar tell their lvalueness?
 
2+2 = ~4
 
It's (a ? b : c), you heretic.
 
no, you can't have lvalues and rvalues as part of the grammar, surely
because in order to determine if an expression is an lvalue or rvalue, you'd need to know the types of what's involved
if you have func();, you can't know if it returns an lvalue or an rvalue until you know what func is
 
Also, the grammar allows x = catch(stuff) {}.
 
4:52 PM
I would have to write a parser that understands all the lvalue/rvalue rules, and most of the language rules w.r.t. name lookup, everything like that
 
@CatPlusPlus I've always wondered about that, since it's (IME) the most common style but it goes both against typography ('the question mark goes where? it goes where the colon goes: here') and also ';'.
 
throw x = throw y;
 
ok, there, I explicitly disallowed statement-less catches again
 
@CatPlusPlus throw x < throw y;, because y throws farther.
 
lol
 
4:54 PM
@DeadMG Perhaps I need to look at the rest of the grammar a bit more to comment on it intelligently.
 
well
it doesn't have templates, so it's not as bad like that
but I do have a few fun things in there myself
like expressions can be types
 
@LucDanton Well, it's an operator, I also prefer x + y instead of x+ y or something.
 
Good point.
I feel awkward when I have the need to split it over several lines however.
 
In maths, I write x +y +z -w. But in code I do x + y + z - w.
 
Then you just don't use it. :P
 
4:56 PM
ok
now you cannot throw throw throw throw throw throw anything
 
@MartinhoFernandes in math i will not use x - y it will be x + (-y)
 
Its usefulness decreases exponentially with complication.
I write every number as ------------x in maths.
 
do you add three extra - if it is negative?
 
Nine.
 
ah
 
4:58 PM
@CatPlusPlus That probably explains why you suck at it, right? ;)
 
ok
 
@MartinhoFernandes Yeah.
 
throw throw throw throw throw throw throw x, and throw x < throw y, that's made my day.
 
I noticed you don't have a catch(...) equivalent.
Is that on purpose?
(Also you could switch '{' statement-list '}' for compound-statement in the catch production).
 

« first day (268 days earlier)      last day (4682 days later) »