[fpc-pascal] Move with pointers to memory
Sven Barth
pascaldragon at googlemail.com
Wed Nov 13 11:19:36 CET 2013
Am 13.11.2013 11:07, schrieb Frederic Da Vitoria:
> 2013/11/13 Rainer Stratmann <rainerstratmann at t-online.de
> <mailto:rainerstratmann at t-online.de>>
>
> On Wednesday 13 November 2013 10:52:23 you wrote:
> > 2013/11/13 Rainer Stratmann <rainerstratmann at t-online.de
> <mailto:rainerstratmann at t-online.de>>
> > > Is there a description of the behaviour of const and var in
> this case?
> > > Why is it not both const or both var?
> >
> > "source" is where the data "comes from", so the procedure won't
> modify it
> > (if there is no memory overlap between source and dest), so it
> is declared
> > as "const"
> > "dest" is where the data is copied to, so the procedure will
> necessarily
> > modify it (if "count" is <> 0), and the procedure should modify
> so it is
> > declared as "var". Actually, IMO it could be declared as "out",
> this would
> > avoid a meaningless warning.
>
> But why does it work without specifying the vars more exactly like
> in other
> cases?
>
>
> You mean, how can it work without using typed variables? In Pascal,
> you don't have to give the type of a parameter, although 99.99% of the
> times you should do it. If you don't do it, you could as well use
> assembly :-) Actually, that's probably how Move is written: in
> assembly language. Of course, since the types were not given in the
> parameter declaration of Move, the compiler can't know the size of the
> data, and you have to give the compiler some indication. That's what
> "count" is for. Move considers the memory as 2 big arrays of bytes,
> one starting at "source", and the second at "dest".
The fallback implementation (for new architectures) is written in
Pascal. See $fpcdir\rtl\inc\generic.inc.
Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20131113/de5bb77f/attachment.html>
More information about the fpc-pascal
mailing list