digitalmars.D - Re: What is nothrow for?
- Yigal Chripun <yigal nowhere.home> Apr 27 2008
Max Samukha Wrote:On Fri, 25 Apr 2008 14:10:23 -0700, Walter Bright <newshound1 digitalmars.com> wrote:Yigal Chripun wrote:BTW, what information does the compiler extract from an attribute?
With nothrow, for example, it can verify that the code inside the function cannot propagate an exception outside of it. I have no idea how you could do that with a user defined attribute.
Like in .NET. And the proposed syntax was taken from C#. A number of intrinsic attributes are treated specially by the IL compiler. For example, DllImport, Obsolete, MarshalAs, StructLayout etc. .NET has a nice extensible attribute system. User defined attributes can be inspected through reflection at run-time. I guess, D could allow to do that at compile time as well.
After some googling I've stumbled upon Nemerle which apparently already implements most of my ideas. Nemerle is built on top of .net and has a bootstrapping compiler (the compiler itself is written in Nemerle). Nemerle provides many cool features including macros and attributes. From what I understand, the way macros work is: you write a macro using their Compiler APIs  and compile it, when you compile your program you also provide to the compiler the compiled macro DLLs and the compiler uses them as "extensions" to the compiler. This is very powerful and allows the user to even add his own syntax to the language. Nemerle also provides CTFE and generics. When I'll have more time, I'll read more about Nemerle and perhaps I'll write a comparison. IMO, D has a lot to learn from Nemerle and Its IMO superior design (based on what I've seen so far).  http://nemerle.org/Class_library -- Yigal
Apr 27 2008