[fpc-pascal] Turbo Pascal Mode Bug?
Hello, I have a peace of code that demonstrates that in the TP mode of freepascal, one can use a function as a procedure. Is this a bug or a normal behavior? My University have replaced ( other time ) freepascal.org, and we must use the archaic Turbo Pascal 6.0, cause they say that freepascal don't respect the ISO Pascal. I let you the code here: program func_as_proc(input,output); function pru_func:boolean; begin writeln ('If I am printed, then you can use a function as a procedure.'); pru_func := TRUE end; { pru_func } begin (* * Prove if a function can be used as a procedure. *) pru_func; end. Thanks in advance. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Turbo Pascal Mode Bug?
Daniël Mantione: Funny. Free Pascal does not respect ISO Pascal, because it respects Turbo Pascal. :) Turbo Pascal in turn, does not respect ISO Pascal, because it respects UCSD Pascal. Is very confusing when talking about Standard Pascal, cause it's not like C/C++ that have standard that is respected by most people ( at least, is what I feel ). My teachers talk about "Standard Pascal" ( no one knows what they are talking about, but you must accept their holy truth ), I knew that TP is not ISOP, but the pupil can't refuse the teacher unless he wants to be bitten. Florian Klaempfl: Normal because FPC emulates TP7, just add {$X+} in TP6 and you get the same behaviour. Is there a way to do the contrary? I mean, to avoid the use of a function as a procedure in freepascal. Thanks. Zaka. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Turbo Pascal mode!!
Some time ago, I posted about this. On the TP mode FreePascal can use a function as a procedure. Florian told me that that was because of the version of the TP emulation. Well, after that, I was happy with that until now. I discovered that, even adding {$x-} to the code, if you put a function inside a "for" or an "if" you can use a function as a procedure: program pru_funcion_como_procedimiento (input,output); {$x-} function pru_func:boolean; begin writeln ('Hola programador.'); pru_func := TRUE; end; { pru_func } procedure pru; var i : integer; begin for i:=1 to 10 do pru_func; end; { pru } begin pru; end. * Is this still normal behaviour? I hope this helps anybody. Zaka. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Pointers in Pascal!!
I have something like this: PStruct = ^Struct; Struct = record num: integer; end; I have a unit to handle that structure ( is a bit more complicated, but is a good example), in this unit I have a procedure that deletes ( disposes ) the pointer. How can I know if a pointer are created or not?, I mean, I don't wont to try to delete something that has not been created yet, but I don't know how to do it, if that is possible. Thanks a lot. Zaka. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Pointers in Pascal!!
Maybe I haven't explain it correctly. What I want is to construct a Unit that contains some procedures, one of them is create(var p : PStruct), and other is delete(var p : PStruct). I don't create anything, the memory is allocated by the create procedure. How can the procedure know if the argument is a pointer already allocated or not? I hope I've explain good enough. Thanks. Zaka. Leonardo M. Ramé escribió: You can assign "nil" to the pointer before using it, then check if PStruct = nil it wasn't created. Leonardo. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Pointers in Pascal!!
It's possible to give a default initialization value to a defined type? I suppose that it isn't, but it would be to easy to resolve that trouble that way. Anyway, I appreciate your help and support. Thanks. Zaka. Jonas Maebe escribió: It cannot know that without help. You have to do such bookkeeping yourself (e.g., as mentioned before, by assigning nil to all pointers when declaring them). That is one of the basic properties of a language with manual memory management. Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal