10-Mar-00 02:38 you wrote:
Hello again,
I wrote:
[...] In principle, it should not be too hard to implement
New (allocator_function, other_parameters)
but with the current implementation of `New' it would need some nontrivial work in the parser.
The following would be much easier to implement (including the implicit `with':-):
New (other_parameters : optional_allocator_function);
What we are still looking for is a syntax to allow for additional parameters (such as a memory pool) to the allocator function. Perhaps like this?
New (other_parameters : optional_allocator_function : parameter, parameter, parameter);
An alternative like this
New (other_parameters : optional_allocator_function (parameter, parameter, parameter));
would look nicer for me, but it would be very difficult to parse.
Hmm. I can not understood why it's so difficult to parse (there are already exist something like new(TMyObject, Init(1,2,3)); -- why it's easy to parse but in case of allocator it's not so?). Just wonder. I'm not sure which syntax is better. Think about mentioned shm_alloc: call will be pstr:=new(string,100:shm_alloc(pool1)); or pstr:=new(string,100:shm_alloc:pool1); but what's definition of shm_alloc ? It's function shm_alloc(size:size_t;var pool:PPool):pointer; TWO arguments, not one! We can invite allocator function (akin to constructor function) but IMHO it'll be overkill. So second version is not only easier to implement but less error-prone as well (this is NOT straight call of ahm_alloc, it's special construct so even shm_call has two paramenters it's Ok to have only one in special construct).
P.S. IMO any syntax will look ugly at first but after few months of active usage will look like most natural thing to do :-) This is how human's mind is done.