I changed part of the ASN1 decoder to use IOBuffer. Some comments
- Stdio.IOBuffer is harder to type than ADT.struct. Can we rename it to Stdio.Buffer? There is already IO in Stdio.
- get_ is shorter than read_. I'm on the fence on if this is a good change though.
- read_buffer dosn't return Stdio.IOBuffer.
An expression of type { IOBuffer = object } cannot be assigned to a variable of type { IOBuffer = object(implements _static_modules._Stdio()->IOBuffer) }.
- It would be great if we could type cast() properly, so we can tell that (string)iobuffer is actually string(8bit).
- There are add_int8 and add_byte, but no read_byte.
- The implementation of add_int8 and add_byte are copies. If we should keep two methods (I'm not convinced), we could make the method registration point to the same C function instead.
The program id part of CMOD is a bit too losely defined. If I change IOBuffer to Buffer it becomes a String.Buffer since the code only concerns itself with the class name. That's a bit dangerous.
- Stdio.IOBuffer is harder to type than ADT.struct. Can we rename it to Stdio.Buffer? There is already IO in Stdio.
I tried Stdio.Buffer but then all types suddenly became String.Buffer. I could not, at that time at least, be bothered to fix the precompiler...
- read_buffer dosn't return Stdio.IOBuffer.
An expression of type { IOBuffer = object } cannot be assigned to a variable of type { IOBuffer = object(implements _static_modules._Stdio()->IOBuffer) }.
Well, yes, that is indeed a bother. The reason is sort of silly, the precompiler is simply not assigning the correct type (it should be rather easy, really, the program id is right there in new_program->id)
- It would be great if we could type cast() properly, so we can tell that (string)iobuffer is actually string(8bit).
Ah, yes, that, it would probably be somewhat easy to implement specifically for cast using a type check callback.
It would however be very nice to have it genrally for all LFUN using operators.
if( arg1 == obj && arg1[lfun) ) { // consume arg1, return type for call( arg1[lfun](arg2) ) }
else if( arg2 == obj && arg2[`lfun) ) { // consume arg2, return type for call( arg2[`lfun](arg1) ) }
pike-devel@lists.lysator.liu.se