On 12/08/2015 10:50 a.m., Clayton wrote:
Hello everyone,

Am looking for someone who could help review my code . As an entry
exercise to D am converting  3 C implementations of popular pattern
matching algorithms. The idea is to have 6 final implementations ( 3
compile-time and 3 runtime) . I think am basically done with the coding,
but being a beginner myself, I feel I need some do some critics so I can
improve (especially on the compiletime ones).

I could have uploaded direct but I think the code may be way too long.

Help will be dearly appreciated.

http://dpaste.dzfl.pl/f0bec44f859e

- COMPILETIME_BM_PRE does it really need to be all caps?
- initialisebmBc interesting naming convention that
- Could do with a format (Mono-D supports this)
- ~~~~~~~~~~
void suffixes(S, I, int i:-1)(S pattern, ref int[size] suff, I size, ref I f, ref int g){
}
void main() {
        int a;
        suffixes("", null, 0, a, a);
}
~~~~~
/d481/f560.d(1): Error: undefined identifier size, did you mean alias size_t? /d481/f560.d(5): Error: template f560.suffixes cannot deduce function from argument types !()(string, typeof(null), int, int, int), candidates are: /d481/f560.d(1): f560.suffixes(S, I, int i : -1)(S pattern, ref int[size] suff, I size, ref I f, ref int g)

Final dummy code I could get working:
~~~~~~~~~~~~~~
void suffixes(S, I, int i:-1)(S pattern, ref int[] suff, I size, ref I f, ref int g){
}
void main() {
        int a, c;
        int[] b;
        suffixes!(string, int, -1)("", b, 0, a, c);
}
~~~~~~~~~~~~~~
Irk, that -1 should be inside a template if condition no there and certainly not using the colon. Also size must be passed in at compile time if being used in the static array like that. Otherwise pass it via a dynamic array like that.




Currently it is really ugly. Format it. Mono-D can do this.
Fix up those template arguments and function arguments. They are all wrong.

There is no way that should compile.

Reply via email to