Re: CTFE vs. traditional metaprogramming

2009-10-13 Thread Don
Yigal Chripun wrote: On 12/10/2009 18:45, BCS wrote: Hello Michel, On 2009-10-09 15:49:42 -0400, Andrei Alexandrescu said: Thanks! I plan to add more text at the end of the chapter that discusses the opportunities of CTFE. Walter revealed to me that CTFE, particularly now after it's been i

Re: CTFE vs. traditional metaprogramming

2009-10-12 Thread Yigal Chripun
On 12/10/2009 18:45, BCS wrote: Hello Michel, On 2009-10-09 15:49:42 -0400, Andrei Alexandrescu said: Thanks! I plan to add more text at the end of the chapter that discusses the opportunities of CTFE. Walter revealed to me that CTFE, particularly now after it's been improved by leaps and b

Re: CTFE vs. traditional metaprogramming

2009-10-12 Thread BCS
Hello language_fan, Sat, 10 Oct 2009 10:26:11 +0200, Don thusly wrote: CTFE doesn't mean "string mixins using CTFE". It just means CTFE. (BTW you can do string mixins with templates only, no CTFE, if you are completely insane). CTFE without mixins is rather limited form of metaprogramming. Y

Re: CTFE vs. traditional metaprogramming

2009-10-12 Thread BCS
Hello Michel, On 2009-10-09 15:49:42 -0400, Andrei Alexandrescu said: Thanks! I plan to add more text at the end of the chapter that discusses the opportunities of CTFE. Walter revealed to me that CTFE, particularly now after it's been improved by leaps and bounds by Don and by Walter himsel

Re: CTFE vs. traditional metaprogramming

2009-10-12 Thread BCS
Hello Don, CTFE doesn't mean "string mixins using CTFE". It just means CTFE. (BTW you can do string mixins with templates only, no CTFE, if you are completely insane). I'm guilty of proving this by building a *parser* that runs at compile time without using CTFE.

Re: CTFE vs. traditional metaprogramming

2009-10-12 Thread language_fan
Mon, 12 Oct 2009 14:01:59 +0200, Don thusly wrote: > language_fan wrote: >> As far as I can tell there is no reason why you cannot call templates >> from a CTFE code. Your code above has two problems: a) it never >> terminates > > It wasn't meant to be a compilable example. > > b) due to some lo

Re: CTFE vs. traditional metaprogramming

2009-10-12 Thread Denis Koroskin
On Mon, 12 Oct 2009 16:01:59 +0400, Don wrote: language_fan wrote: Mon, 12 Oct 2009 12:07:19 +0200, Don thusly wrote: language_fan wrote: Sat, 10 Oct 2009 10:30:31 +0200, Don thusly wrote: The more fundamental problem is that you can't instantiate a template from inside CTFE. IE, you can

Re: CTFE vs. traditional metaprogramming

2009-10-12 Thread Don
language_fan wrote: Mon, 12 Oct 2009 12:07:19 +0200, Don thusly wrote: language_fan wrote: Sat, 10 Oct 2009 10:30:31 +0200, Don thusly wrote: The more fundamental problem is that you can't instantiate a template from inside CTFE. IE, you can cross from the "compile-time world" to the "runtim

Re: CTFE vs. traditional metaprogramming

2009-10-12 Thread language_fan
Mon, 12 Oct 2009 12:07:19 +0200, Don thusly wrote: > language_fan wrote: >> Sat, 10 Oct 2009 10:30:31 +0200, Don thusly wrote: >> >>> The more fundamental problem is that you can't instantiate a template >>> from inside CTFE. IE, you can cross from the "compile-time world" to >>> the "runtime wor

Re: CTFE vs. traditional metaprogramming

2009-10-12 Thread Don
language_fan wrote: Sat, 10 Oct 2009 10:26:11 +0200, Don thusly wrote: CTFE doesn't mean "string mixins using CTFE". It just means CTFE. (BTW you can do string mixins with templates only, no CTFE, if you are completely insane). CTFE without mixins is rather limited form of metaprogramming. Yo

Re: CTFE vs. traditional metaprogramming

2009-10-12 Thread Don
language_fan wrote: Sat, 10 Oct 2009 10:30:31 +0200, Don thusly wrote: The more fundamental problem is that you can't instantiate a template from inside CTFE. IE, you can cross from the "compile-time world" to the "runtime world" only once -- you can never get back. That's not exactly true. A

Re: CTFE vs. traditional metaprogramming

2009-10-10 Thread Michel Fortin
On 2009-10-10 16:56:33 -0400, language_fan said: And from that point of view, you can see templates as an compiled, optimized version of runtime reflection and type creation capabilities. Runtime reflection can be really expensive computationally, but it becomes useful when you need mobile co

Re: CTFE vs. traditional metaprogramming

2009-10-10 Thread language_fan
Fri, 09 Oct 2009 16:49:19 -0400, Jarrett Billingsley thusly wrote: > Where CTFE wins at metaprogramming: > > Liiists. If you have a list of something, it's far easier to > deal with in an imperative CTFE function than in an awkwardly recursive > template. Edge cases (first, last items) ar

Re: CTFE vs. traditional metaprogramming

2009-10-10 Thread language_fan
Fri, 09 Oct 2009 20:20:02 -0400, Michel Fortin thusly wrote: > But an interesting thing I realized in the last few months is this: all > you can do with a template you can also do at runtime provided > sufficient runtime reflection capabilities. Even creating types! This is a well known fact.. >

Re: CTFE vs. traditional metaprogramming

2009-10-10 Thread language_fan
Sat, 10 Oct 2009 01:21:32 -0400, bearophile thusly wrote: > Jeremie Pelletier: > >> I would rather have TypeInfo usable at compile time than a "type" type. > > That's useful, but it's not enough. So you may want both. Sometimes all > you want to pass to a function is a type, to replace some of

Re: CTFE vs. traditional metaprogramming

2009-10-10 Thread language_fan
Sat, 10 Oct 2009 10:26:11 +0200, Don thusly wrote: > CTFE doesn't mean "string mixins using CTFE". It just means CTFE. (BTW > you can do string mixins with templates only, no CTFE, if you are > completely insane). CTFE without mixins is rather limited form of metaprogramming. You can basically o

Re: CTFE vs. traditional metaprogramming

2009-10-10 Thread language_fan
Sat, 10 Oct 2009 10:30:31 +0200, Don thusly wrote: > The more fundamental problem is that you can't > instantiate a template from inside CTFE. IE, you can cross from the > "compile-time world" to the "runtime world" only once -- you can never > get back. That's not exactly true. Also both templat

Re: CTFE vs. traditional metaprogramming

2009-10-10 Thread Don
Jarrett Billingsley wrote: On Fri, Oct 9, 2009 at 4:57 PM, Sean Kelly wrote: == Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article Thanks! I plan to add more text at the end of the chapter that discusses the opportunities of CTFE. Walter revealed to me that CTFE, particul

Re: CTFE vs. traditional metaprogramming

2009-10-10 Thread Don
Jarrett Billingsley wrote: On Fri, Oct 9, 2009 at 3:49 PM, Andrei Alexandrescu wrote: Thanks! I plan to add more text at the end of the chapter that discusses the opportunities of CTFE. Walter revealed to me that CTFE, particularly now after it's been improved by leaps and bounds by Don and b

Re: CTFE vs. traditional metaprogramming

2009-10-09 Thread bearophile
Jeremie Pelletier: > I would rather have TypeInfo usable at compile time than a "type" type. That's useful, but it's not enough. So you may want both. Sometimes all you want to pass to a function is a type, to replace some of the use cases of templates. Time ago I have shown some usage example

Re: CTFE vs. traditional metaprogramming

2009-10-09 Thread Michel Fortin
On 2009-10-09 15:49:42 -0400, Andrei Alexandrescu said: Thanks! I plan to add more text at the end of the chapter that discusses the opportunities of CTFE. Walter revealed to me that CTFE, particularly now after it's been improved by leaps and bounds by Don and by Walter himself, could ob

Re: CTFE vs. traditional metaprogramming

2009-10-09 Thread Jeremie Pelletier
bearophile wrote: Sean Kelly: CTFE is great for working with values while template metaprogramming is great for working with types. String mixins make CTFE good at working with types as well, but I wouldn't consider them a novice-level feature. If a "type" type is added to the language (and

Re: CTFE vs. traditional metaprogramming

2009-10-09 Thread bearophile
Sean Kelly: > CTFE is great for working with values while template metaprogramming is > great for working with types. String mixins make CTFE good at working > with types as well, but I wouldn't consider them a novice-level feature. If a "type" type is added to the language (and few other minor

Re: CTFE vs. traditional metaprogramming

2009-10-09 Thread Jarrett Billingsley
On Fri, Oct 9, 2009 at 4:57 PM, Sean Kelly wrote: > == Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article >> Thanks! >> I plan to add more text at the end of the chapter that discusses the >> opportunities of CTFE. Walter revealed to me that CTFE, particularly now >> after it

Re: CTFE vs. traditional metaprogramming

2009-10-09 Thread Sean Kelly
== Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article > Thanks! > I plan to add more text at the end of the chapter that discusses the > opportunities of CTFE. Walter revealed to me that CTFE, particularly now > after it's been improved by leaps and bounds by Don and by Walter

Re: CTFE vs. traditional metaprogramming

2009-10-09 Thread Jason House
Andrei Alexandrescu Wrote: > > One question that bugs me is, where do you draw the line? Say there's a > metaprogramming problem at hand. How to decide on solving it with CTFE > vs. solving it with templates? It would be great to have a simple > guideline that puts in contrast the pluses and mi

Re: CTFE vs. traditional metaprogramming

2009-10-09 Thread Jarrett Billingsley
On Fri, Oct 9, 2009 at 3:49 PM, Andrei Alexandrescu wrote: > Thanks! > > > I plan to add more text at the end of the chapter that discusses the > opportunities of CTFE. Walter revealed to me that CTFE, particularly now > after it's been improved by leaps and bounds by Don and by Walter himself, >

Re: CTFE vs. traditional metaprogramming

2009-10-09 Thread Jarrett Billingsley
On Fri, Oct 9, 2009 at 4:28 PM, Lutger wrote: > Jarrett Billingsley wrote: > >> The second someone suggests parsing D code with CTFE, I'm out of here. >> I mean I'm leaving the community. Period. > > Here, for you: > > http://www.addletters.com/pictures/bart-simpson-generator/bart-simpson- > gener

Re: CTFE vs. traditional metaprogramming

2009-10-09 Thread Lutger
Jarrett Billingsley wrote: > The second someone suggests parsing D code with CTFE, I'm out of here. > I mean I'm leaving the community. Period. Here, for you: http://www.addletters.com/pictures/bart-simpson-generator/bart-simpson- generator.php?line=I+will+not+parse+D+code+with+CTFE!

Re: CTFE vs. traditional metaprogramming

2009-10-09 Thread Nick Sabalausky
"Andrei Alexandrescu" wrote in message news:hao44m$2g5...@digitalmars.com... > > It is quite possible that templates get relegated to parameterized > functions and types, whereas all heavy lifting in metaprogramming should > be carried with CTFE. > I've been told that the reason C#'s generics

Re: CTFE vs. traditional metaprogramming

2009-10-09 Thread Jarrett Billingsley
On Fri, Oct 9, 2009 at 3:49 PM, Andrei Alexandrescu wrote: > Thanks! > > > I plan to add more text at the end of the chapter that discusses the > opportunities of CTFE. Walter revealed to me that CTFE, particularly now > after it's been improved by leaps and bounds by Don and by Walter himself, >

CTFE vs. traditional metaprogramming

2009-10-09 Thread Andrei Alexandrescu
Thanks! I plan to add more text at the end of the chapter that discusses the opportunities of CTFE. Walter revealed to me that CTFE, particularly now after it's been improved by leaps and bounds by Don and by Walter himself, could obviate a lot of the traditional metaprogramming techniques d