July 26, 2012
> 3. Is there any way of executing code or programs during compile
> time?
> I've seen an example of CTFE (Compile Time Function Evaluation),
> although I'm unsure if this works for stuff like classes.
> However, I am considering more advanced execution (not constants)
> such as printing to a file during compiling for stuff like how
> long compiling a certain function/template takes.

You can call any safe and pure D code at compile time (none of the code has to be marked pure explicitly, but it cannot access any static or global variables, call C code, access files, etc.) This is called CTFE=Compile-Time Function Evaluation.

The "pure" limitation isn't a huge restriction, since you can still edit member variables (fields) and the compiler can memoize the results of CTFE... although I don't know if it memoizes automatically, or if you have to use a template to accomplish it. For example if I do

enum twoPi = computePi() + computePi();

I don't know if the compiler computes PI once or twice. Does someone know? But if I define this template:

@property auto memoize(T, T code)() { return code; }

enum twoPi = memoize!(double,computePi()) + memoize!(double,computePi());

Then computePi is surely called only once, and thus you can cache the result of any computation for repeated use. (I don't know how to get the type 'double' to be inferred automatically, though.) You can also, of course, use enums for this purpose:

enum pi = computePi(); // computed only once
enum twoPi = pi + pi;

I don't think you can run "programs" at compile-time, but since you can call ordinary functions and use arbitrarily large structs, you can accomplish a lot. I believe the current released build, 2.059, can't use classes at compile time, but bearophile just implied that 2.060 can.

> 5. Why not support other operators like $, #, and @?
> This is more of a rhetorical... as I know the language doesn't
> need them, nor would I know if they would be binary/unary
> prefix/etc or the precedence... although they would be nice to
> have. Specifically I'd like $prefix to be stringification.

Just to clarify, because other people are making it sound like D could do this... no, D does not offer user-defined operators, only overloading of predefined operators. User-defined ops would certainly be a nice feature that I would like to have, but the D developers have too much to do already. Personally I think the D syntax and rules feel too ad-hoc and unintuitive right now; it should be simplified slightly, formalized more clearly, and debugged further before yet more features are piled on.
July 26, 2012
On Thu, Jul 26, 2012 at 9:17 AM, Andrej Mitrovic <andrej.mitrovich@gmail.com
> wrote:

> On 7/26/12, Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> wrote:
> > The OP is likely new to the community, so throwing acronyms around may not be helpful.
>
> http://dlang.org/glossary.html
>
> Now if someone would stop fiddling with the damn javascript which keeps erroring out.. I'm beginning to join the Nick camp w.r.t. JS. :p
>

What are the errors and what browser (with version) are you using? There
were errors in the Chrome Beta release until recently (they stopped after
we updated hyphenator.js).

I just tested in:
- Chrome 21.0.1180.55
- Firefox 8.0.1
- Firefox 12.0
- Firefox 14.0.1
- Opera 10.63
- Opera 12.00
- IE 9.0.8112.16421

and saw nothing wrong.


July 26, 2012
On 2012-07-26 16:53, Andrei Alexandrescu wrote:

> What happened to __traits(allMembers, module_name)? It doesn't list the
> contents of the current scope, but instead that of a module (including
> the current one).

It can be used on classes and structs (I assume) as well,

-- 
/Jacob Carlborg
July 26, 2012
On Thursday, 26 July 2012 at 11:20:35 UTC, Wes wrote:
> Can you do this in D? If not then what other language?
>
Nimrod (http://nimrod-code.org/) can do 2, 3, 4, 5 of your list. (1 is planned.)
2 can be done very efficiently directly for tuples; for classes it can currently only be done with RTTI. And Nimrod uses $ for stringification. ;-)


July 26, 2012
On Thursday, 26 July 2012 at 19:02:15 UTC, Araq wrote:
> ;-)

Further context: Araq is the guy behind Nimrod.

Man, we should totally infiltrate their forums as well.

David,
serious as ever
July 26, 2012
On Thursday, 26 July 2012 at 19:38:41 UTC, David Nadlinger wrote:
> On Thursday, 26 July 2012 at 19:02:15 UTC, Araq wrote:
>> ;-)
>
> Further context: Araq is the guy behind Nimrod.
>
> Man, we should totally infiltrate their forums as well.
>
> David,
> serious as ever

He explicitely asked about other programming languages...

July 26, 2012
On Thu, 26 Jul 2012 21:44:24 +0200, Araq <rumpf_a@web.de> wrote:

> On Thursday, 26 July 2012 at 19:38:41 UTC, David Nadlinger wrote:
>> On Thursday, 26 July 2012 at 19:02:15 UTC, Araq wrote:
>>> ;-)
>>
>> Further context: Araq is the guy behind Nimrod.
>>
>> Man, we should totally infiltrate their forums as well.
>>
>> David,
>> serious as ever
>
> He explicitely asked about other programming languages...

That's it! He's using logic against us!

We're just pulling your leg, Araq. This reminds me, I should
perhaps do more with Nimrod than just install it...

-- 
Simen
July 26, 2012
On Thu, 26 Jul 2012 17:17:39 +0200
Andrej Mitrovic <andrej.mitrovich@gmail.com> wrote:

> On 7/26/12, Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> wrote:
> > The OP is likely new to the community, so throwing acronyms around may not be helpful.
> 
> http://dlang.org/glossary.html
> 
> Now if someone would stop fiddling with the damn javascript which keeps erroring out.. I'm beginning to join the Nick camp w.r.t. JS. :p

JavaScript is a technology (from the makers of clearly the greatest web browser of all time - Netscape) whose primary usage, and indeed killer feature, is to enable people to develop new and exciting ways to make the web slower, more broken, and more obnoxious than could ever be achieved with mere HTML/CSS alone. This, of course, is a major win for humanity in general, and is something we can all be proud of.

http://semitwist.com/articles/article/view/my-awesome-web-development-game

July 26, 2012
On Thu, Jul 26, 2012 at 05:59:08PM -0400, Nick Sabalausky wrote:
> On Thu, 26 Jul 2012 17:17:39 +0200
> Andrej Mitrovic <andrej.mitrovich@gmail.com> wrote:
[...]
> > Now if someone would stop fiddling with the damn javascript which keeps erroring out.. I'm beginning to join the Nick camp w.r.t. JS. :p
> 
> JavaScript is a technology (from the makers of clearly the greatest web browser of all time - Netscape) whose primary usage, and indeed killer feature, is to enable people to develop new and exciting ways to make the web slower, more broken, and more obnoxious than could ever be achieved with mere HTML/CSS alone. This, of course, is a major win for humanity in general, and is something we can all be proud of.
> 
> http://semitwist.com/articles/article/view/my-awesome-web-development-game

I'm guilty of turning <i> into <em>, actually. You may shoot me now.

(Actually, I resisted many attempts at introducing bold and italics buttons on my web-based editing page. I even introduced a way of indicating which table cells are headers, so that styling will work properly instead of half-assed manual bolding. But no, the users clamored for bold and italics until they threatened to mob me (ok, that last part may be an exaggeration), and so the horrible bold/italics buttons appeared. So far, I've resisted adding a "red" button (apparently, bold and italics aren't enough, sometimes you want something in RED too). I managed to evade that one by having a select box for the status field of the items, one option of which is styled red, and insisting that's the only place red is allowed. We'll see how long I hold out on that one.)


T

-- 
Those who don't understand Unix are condemned to reinvent it, poorly.
July 26, 2012
On 7/26/2012 4:20 AM, Wes wrote:
> 5. Why not support other operators like $, #, and @?
> This is more of a rhetorical... as I know the language doesn't
> need them, nor would I know if they would be binary/unary
> prefix/etc or the precedence... although they would be nice to
> have.

The question shouldn't be framed as "why not X?" but as "does the utility of having X justify placing in in the language?"

What is the utility of operators $, # and @?


> Specifically I'd like $prefix to be stringification.

Can you please be more specific about what this might do?
1 2 3 4
Top | Discussion index | About this forum | D home