Re: NotNull Parser
I'd like to share my files with you. Here is the not_null_parser: http://dpaste.dzfl.pl/c522bd9f re_name: http://dpaste.dzfl.pl/96928cd6 And the precompiler (which uses the above two): http://dpaste.dzfl.pl/59de30f4 If you want to use it, compile all three and move them into dmd(2) windows bin. Then if you like to compile a file with the precompiler, write precompiler instead of dmd. Nothing more. If you only like to _convert_ (not compile) files from invalid code with NotNull tokens (@) into valid D code with precondition and assertions write not_null_parser YOUR_FILE.d [#t]. The optional parameter #t only if you like to have a copy with NotNull tokens (see my first post for more informations). You must have a copy if you want to use re_name. I also wrote a short website with a online converter (in php) to offer such conversion online without download anything, but i'm a windows user and my webspace use a linux server, so i cannot offer anything. :/
Re: NotNull Parser
On Friday, 3 August 2012 at 10:42:48 UTC, David wrote: Yay Preprocessors 3 irony? :P
Re: NotNull Parser
On 08/03/2012 12:38 PM, Namespace wrote: In context with my post here: http://forum.dlang.org/thread/gajrorlwnrriljxnx...@forum.dlang.org#post-egvyqwkcqjglhrvujkar:40forum.dlang.org I wrote the last days a NotNull Parser. What is this? The NotNull Parser generate for parameter statements with a following ? valid preconditions. Example: [code] void foo(Object? o) { // do something with o } [/code] will convert into The notation 'T?' is normally used for a nullable type.
Re: NotNull Parser
On Friday, 3 August 2012 at 10:53:02 UTC, Timon Gehr wrote: On 08/03/2012 12:38 PM, Namespace wrote: In context with my post here: http://forum.dlang.org/thread/gajrorlwnrriljxnx...@forum.dlang.org#post-egvyqwkcqjglhrvujkar:40forum.dlang.org I wrote the last days a NotNull Parser. What is this? The NotNull Parser generate for parameter statements with a following ? valid preconditions. Example: [code] void foo(Object? o) { // do something with o } [/code] will convert into The notation 'T?' is normally used for a nullable type. I can change the operator easily. Any better suggestions?
Re: NotNull Parser
Timon Gehr: The notation 'T?' is normally used for a nullable type. Right. that's why I have suggested a trailing @: http://d.puremagic.com/issues/show_bug.cgi?id=4571 Namespace: void foo(Object? o) { // do something with o } [/code] will convert into [code] void foo(Object o, string filename = __FILE__, uint line = __LINE__) in { if (o is null) throw new Exception(Object is null., filename, line); } body { // do something with o } [/code] Object@ is a type, so if you write: void foo(Object@ o) {... It means the compiler statically refuses you to give a nullable type to foo. So inside foo there is no need for a run time test. Good work :-) Bye, bearophile
Re: NotNull Parser
Object@ is a type, so if you write: void foo(Object@ o) {... It means the compiler statically refuses you to give a nullable type to foo. So inside foo there is no need for a run time test. Good work :-) Bye, bearophile Change line 14 from OpToken = r\?, into OpToken = r\@, And it works as you like. ;) I will change it too.
Re: NotNull Parser
No further suggestions or criticism?