Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)

2019-01-19 Thread Mark via Digitalmars-d-announce
On Friday, 18 January 2019 at 20:29:08 UTC, H. S. Teoh wrote: That would work, but it would also suffer from all the same problems as macro-based programming in C. The compiler would be unable to detect when you accidentally pasted type names together where you intended to be separate, the

Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)

2019-01-18 Thread Paul Backus via Digitalmars-d-announce
On Friday, 18 January 2019 at 20:03:48 UTC, Mark wrote: [...] Represent types as strings, CTFE them as you see fit, and output a string that can then be mixin'ed to use the actual type. :) Two problems: 1) Mixing in a string is unhygienic. If two modules (or two scopes in the same module)

Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)

2019-01-18 Thread Stefan Koch via Digitalmars-d-announce
On Friday, 18 January 2019 at 20:32:35 UTC, Jacob Carlborg wrote: On 2019-01-18 20:28, Stefan Koch wrote: The only difference that type-functions have from what you describe is that it does not need to occupy a keyword 'type'. You're using "alias" instead of my "type" keyword? yes. After

Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)

2019-01-18 Thread Jacob Carlborg via Digitalmars-d-announce
On 2019-01-18 20:28, Stefan Koch wrote: The only difference that type-functions have from what you describe is that it does not need to occupy a keyword 'type'. You're using "alias" instead of my "type" keyword? -- /Jacob Carlborg

Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)

2019-01-18 Thread H. S. Teoh via Digitalmars-d-announce
On Fri, Jan 18, 2019 at 08:03:48PM +, Mark via Digitalmars-d-announce wrote: [...] > Why not do away with AliasSeq and use strings all the way? > > string Constify(string type) > { > // can add input checks here > return "const(" ~ type ~ ")"; > } > > void main() > { > import

Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)

2019-01-18 Thread Mark via Digitalmars-d-announce
On Thursday, 17 January 2019 at 20:47:38 UTC, Steven Schveighoffer wrote: well, there was no static foreach for that article (which I admit I didn't read, but I know what you mean). But it's DEFINITELY not as easy as it could be: import std.conv; alias AliasSeq(P...) = P; template

Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)

2019-01-18 Thread Stefan Koch via Digitalmars-d-announce
On Friday, 18 January 2019 at 10:23:11 UTC, Jacob Carlborg wrote: On 2019-01-17 23:44, H. S. Teoh wrote: YES! This is the way it should be. Type-tuples become first class citizens, and you can pass them around to functions and return them from functions No no no, not only type-tuples, you

Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)

2019-01-18 Thread H. S. Teoh via Digitalmars-d-announce
On Fri, Jan 18, 2019 at 11:23:11AM +0100, Jacob Carlborg via Digitalmars-d-announce wrote: > On 2019-01-17 23:44, H. S. Teoh wrote: > > > YES! This is the way it should be. Type-tuples become first class > > citizens, and you can pass them around to functions and return them > > from functions

Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)

2019-01-18 Thread H. S. Teoh via Digitalmars-d-announce
On Thu, Jan 17, 2019 at 05:32:52PM -0800, Walter Bright via Digitalmars-d-announce wrote: > On 1/17/2019 11:31 AM, H. S. Teoh wrote: > > [...] > > Thanks for the thoughtful and well-written piece. > > But there is a counterpoint: symmetry in mathematics is one thing, but > symmetry in human

Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)

2019-01-18 Thread Jacob Carlborg via Digitalmars-d-announce
On 2019-01-17 23:44, H. S. Teoh wrote: Interesting. Is it possible to assign a "fake" mangle to type functions that never actually gets emitted into the object code, but just enough to make various internal compiler stuff that needs to know the mangle work properly? Not sure that would be

Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)

2019-01-18 Thread Jacob Carlborg via Digitalmars-d-announce
On 2019-01-17 23:44, H. S. Teoh wrote: YES! This is the way it should be. Type-tuples become first class citizens, and you can pass them around to functions and return them from functions No no no, not only type-tuples, you want types to be first class citizens. This makes it possible to

Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)

2019-01-17 Thread Walter Bright via Digitalmars-d-announce
On 1/17/2019 11:31 AM, H. S. Teoh wrote: [...] Thanks for the thoughtful and well-written piece. But there is a counterpoint: symmetry in mathematics is one thing, but symmetry in human intuition is not. Anytime one is dealing in human interfaces, one runs into this. I certainly did with

Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)

2019-01-17 Thread Walter Bright via Digitalmars-d-announce
On 1/17/2019 8:06 AM, bpr wrote: Was that a pre C++11 version of C++, or a more modern one? pre C++11

Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)

2019-01-17 Thread Stefan Koch via Digitalmars-d-announce
On Thursday, 17 January 2019 at 22:44:08 UTC, H. S. Teoh wrote: On Thu, Jan 17, 2019 at 10:20:24PM +, Stefan Koch via Digitalmars-d-announce wrote: P.S. There is one caveat: because of how type-functions work they cannot, you cannot create a non-anonymous symbol inside a type-function,

Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)

2019-01-17 Thread Johannes Loher via Digitalmars-d-announce
Am 17.01.19 um 23:20 schrieb Stefan Koch: > For 2 years I have pondered this problem, and I did come up with a > solution. > It's actually not that hard to have CTFE interact with type-tuples. > You can pass them as function parameters, or return them if you wish. > Of course a type-tuple

Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)

2019-01-17 Thread H. S. Teoh via Digitalmars-d-announce
On Thu, Jan 17, 2019 at 10:20:24PM +, Stefan Koch via Digitalmars-d-announce wrote: > On Thursday, 17 January 2019 at 19:31:24 UTC, H. S. Teoh wrote: [...] > > Coming back to the D example at the end, I totally agree with the > > sentiment that D templates, in spite of their significant > >

Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)

2019-01-17 Thread Stefan Koch via Digitalmars-d-announce
On Thursday, 17 January 2019 at 19:31:24 UTC, H. S. Teoh wrote: On Thu, Jan 17, 2019 at 06:03:07PM +, Paul Backus via Digitalmars-d-announce wrote: [...] [2] https://bartoszmilewski.com/2009/10/21/what-does-haskell-have-to-do-with-c/ [...] Coming back to the D example at the end, I

Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)

2019-01-17 Thread Steven Schveighoffer via Digitalmars-d-announce
On 1/17/19 2:31 PM, H. S. Teoh wrote: On Thu, Jan 17, 2019 at 06:03:07PM +, Paul Backus via Digitalmars-d-announce wrote: [...] [2] https://bartoszmilewski.com/2009/10/21/what-does-haskell-have-to-do-with-c/ [...] Haha, seems D did better than C++ in this respect, but not quite at the

Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)

2019-01-17 Thread H. S. Teoh via Digitalmars-d-announce
On Thu, Jan 17, 2019 at 06:03:07PM +, Paul Backus via Digitalmars-d-announce wrote: [...] > [2] > https://bartoszmilewski.com/2009/10/21/what-does-haskell-have-to-do-with-c/ [...] Haha, seems D did better than C++ in this respect, but not quite at the level of Haskell. The C++ example of a

Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)

2019-01-17 Thread Paul Backus via Digitalmars-d-announce
On Thursday, 17 January 2019 at 16:06:39 UTC, bpr wrote: On Thursday, 17 January 2019 at 01:59:29 UTC, Walter Bright wrote: Bartosz Milewski is a C++ programmer and a Haskell fan. He once gave a presentation at NWCPP where he wrote a few lines of Haskell code. Then, he showed the same code

Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)

2019-01-17 Thread bpr via Digitalmars-d-announce
On Thursday, 17 January 2019 at 01:59:29 UTC, Walter Bright wrote: On 1/16/2019 4:19 PM, H. S. Teoh wrote: On Wed, Jan 16, 2019 at 11:43:19PM +, John Carter via Digitalmars-d-announce wrote: [...] Yes, that's one of the outstanding qualities of D, and one that I was immensely impressed

Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)

2019-01-17 Thread H. S. Teoh via Digitalmars-d-announce
On Wed, Jan 16, 2019 at 05:59:29PM -0800, Walter Bright via Digitalmars-d-announce wrote: [...] > Bartosz Milewski is a C++ programmer and a Haskell fan. He once gave a > presentation at NWCPP where he wrote a few lines of Haskell code. > Then, he showed the same code written using C++ template >

Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)

2019-01-16 Thread Meta via Digitalmars-d-announce
On Thursday, 17 January 2019 at 01:59:29 UTC, Walter Bright wrote: Bartosz Milewski is a C++ programmer and a Haskell fan. He once gave a presentation at NWCPP where he wrote a few lines of Haskell code. Then, he showed the same code written using C++ template metaprogramming. The Haskell

Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)

2019-01-16 Thread Walter Bright via Digitalmars-d-announce
On 1/16/2019 4:19 PM, H. S. Teoh wrote: On Wed, Jan 16, 2019 at 11:43:19PM +, John Carter via Digitalmars-d-announce wrote: ...I do find it remarkable that I can read the d code quite easily without reaching for the reference manual, but to make sense of his C++, it sends me trawling

Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)

2019-01-16 Thread Walter Bright via Digitalmars-d-announce
On 1/16/2019 3:43 PM, John Carter wrote: Somebody on the C++ side has written a reply https://brevzin.github.io/c++/2019/01/15/if-constexpr-isnt-broken/ From the article: D (with corrections): static if (maxLength < 0xFFFE) { alias CellIdx = uint16_t; } else { alias CellIdx

Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)

2019-01-16 Thread H. S. Teoh via Digitalmars-d-announce
On Wed, Jan 16, 2019 at 11:43:19PM +, John Carter via Digitalmars-d-announce wrote: [...] > Given that I have probably written a lot more C++ code in my life than > d... > > ...I do find it remarkable that I can read the d code quite easily > without reaching for the reference manual, but to