Re: int8 prolog

Jan Wielemaker <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
On 02/24/2014 07:23 AM, atom meta wrote:
> Hi
>
> I was wondering if I can declare int8 variable in SWI-Prolog. For example:
>
> age(50). % for this fact I want to keep the value small so that I can save
> up more memory.
>
> How could I do this in SWI-Prolog?

Not. It is also not that useful. Having such types only makes sense for
arrays (or columns in databases), where it results in a compact
representation of the data. So, it could be useful to have a declaration
`age/100 is a compound with 100 int8 values'.  But, then we do
functor(Term, age, 100) and we have a term with 100 variables.  All these
variables must be constrained to 0..255.  In addition, we need to be able
to do arg(25, Term, Age).  Now we get variable sharing, which means we
place the location of one variable in the other.  But, this is not going
to fit in 0..255 :-(.  For short, the minimal sensible size for an object
must be capable to address most of the address space and is thus 32 or
64 bits on todays machines.  Prolog will use that as long as it fits and
switch to an indirect value (where the cell points to the real location)
if the integer does not fit.

Well, for int8 arrays you can use strings.  You cannot have `variable
characters' inside them though.

	Cheers --- Jan

> Thank you in advance!
>
> Regards,
> Joe.
> -------------- next part --------------
> HTML attachment scrubbed and removed
> _______________________________________________
> SWI-Prolog mailing list
> [email protected]
> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.