Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2006-11

Set format

16 messages · 8 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Jonas Maebe

Hello,

I have a quick question: are there (m)any people here who store/load sets to/from files?

The reason is that we are considering to change the internal format of sets in FPC on big endian machines. The reason is that this would be necessary to allow byte-packing of sets (so that e.g. a set of 0..63 would only occupy 1 byte as opposed to 4 like is currently the case). An added advantage would be that this would make gdb (the debugger used by Xcode) display sets correctly on PowerPC's and other big endian machines.

I'm afraid this may cause backward compatibility problems, but if not too many people store sets in binary files, that fear is unfounded.

Thanks,

Jonas

Reply by email

Ewald Horn
to Jonas Maebe

Hi,

is it possible to keep a legacy reader in place ? That way it'll be easy to read old data and convert it to the new format and have little impact on historic data. If you happen to work on a big endian machine you could then do a once-off conversion.

Kind regards
Ewald Horn

Reply by email

Jonas Maebe
to Ewald Horn
Ewald Horn wrote
is it possible to keep a legacy reader in place ? That way it'll be easy to read old data and convert it to the new format and have little impact on historic data. If you happen to work on a big endian machine you could then do a once-off conversion.

We'd definitely provide a conversion function to convert from the old format to the new one, yes.

Jonas

Reply by email

Tom Verhoeff
to Jonas Maebe: I have a quick question: are there (m)any people here who store/load sets to/from files?…
Jonas Maebe wrote
I have a quick question: are there (m)any people here who store/load sets to/from files?

I do not mix sets and files, but I do mix sets and Single/Double in a record to decompose floating point numbers.

However, I don't see a big problem in converting my unit to accommodate a different internal set representation. (It might even simplify matters for me.)

Show quoted text 10 lines
The reason is that we are considering to change the internal format of sets in FPC on big endian machines. The reason is that this would be necessary to allow byte-packing of sets (so that e.g. a set of 0..63 would only occupy 1 byte as opposed to 4 like is currently the case). An added advantage would be that this would make gdb (the debugger used by Xcode) display sets correctly on PowerPC's and other big endian machines. I'm afraid this may cause backward compatibility problems, but if not too many people store sets in binary files, that fear is unfounded.

I would think that in general the advantages you describe outweigh the disadvantages.

For purposes of converting between one representation and the other, it might be nice to provide a means to declare "old"sets, which use the current representation, _alongside_ the new sets, which use the improved representation. Then it would be fairly straightforward to write a conversion program that reads in the old format and writes out the new format.

Thanks for enquiring,

Tom

E-MAIL: T.Verhoeff @ TUE.NL | Fac. of Math. & Computing Science PHONE: +31 40 247 41 25 | Eindhoven University of Technology FAX: +31 40 247 54 04 | PO Box 513, NL-5600 MB Eindhoven http://www.win.tue.nl/~wstomv/ | The Netherlands

Reply by email

Marco van de Voort
to Jonas Maebe: We'd definitely provide a conversion function to convert from the old format to the new…
Show quoted text 9 lines
On 14 nov 2006, at 12:32, Ewald Horn wrote: > is it possible to keep a legacy reader in place ? That way it'll be > easy to read old data and convert it to the new format and have > little impact on historic data. If you happen to work on a big > endian machine you could then do a once-off conversion. We'd definitely provide a conversion function to convert from the old format to the new one, yes.
{$packset} support ?

Reply by email

Jonas Maebe
to Tom Verhoeff: I do not mix sets and files, but I do mix sets and Single/Double in a record to decompose…
Tom Verhoeff wrote 8 lines
For purposes of converting between one representation and the other, it might be nice to provide a means to declare "old"sets, which use the current representation, _alongside_ the new sets, which use the improved representation. Then it would be fairly straightforward to write a conversion program that reads in the old format and writes out the new format.

It would be much simpler to simply provide conversion functions, because otherwise the code generator is going to become a real mess.

Jonas

Reply by email

Jonas Maebe
to Marco van de Voort: {$packset} support ?
Marco van de Voort wrote 9 lines
>> is it possible to keep a legacy reader in place ? That way it'll be >> easy to read old data and convert it to the new format and have >> little impact on historic data. If you happen to work on a big >> endian machine you could then do a once-off conversion. > > We'd definitely provide a conversion function to convert from the old > format to the new one, yes. {$packset} support ?

That does not allow for format conversion (even if it allows you to set the old set format).

Jonas

Reply by email

Marco van de Voort
to Jonas Maebe: That does not allow for format conversion (even if it allows you to set the old set…
Show quoted text 14 lines
On 14 nov 2006, at 13:20, Marco van de Voort wrote: >>> is it possible to keep a legacy reader in place ? That way it'll be >>> easy to read old data and convert it to the new format and have >>> little impact on historic data. If you happen to work on a big >>> endian machine you could then do a once-off conversion. >> >> We'd definitely provide a conversion function to convert from the old >> format to the new one, yes. > > {$packset} support ? That does not allow for format conversion (even if it allows you to set the old set format).

I was a bit brief, but I was thinking a bit about my usage of sets in the past, which was usually part of a record. So more about different sizes, not endian conversion.

It would then be possible to have the same record-with-set twice with different formats, and generate conversion routines for the datastructure.

However this would only matter if you have a gigantic number of these kind of records. So nevermind.

(For me no conversion needed btw, due to the Delphi<->FPC difference I stayed away from sets in files)

Reply by email

Florian Klaempfl
to Marco van de Voort
Show quoted text 7 lines
Another question, do you intend to fix the other size problem too? (another Delphi incompatability) I mean by this sets of x..y having a size of roundup((y-z+1)/8) with z as x rounded down to the lower multiple of 8. IOW, a set of 79..83 is two bytes in delphi.

Yes, this is the final goal. My approach was to make things completetly delphi compatible. This wouldn't cause much incompatibilities on little endian system with the old behaviour but on big endian systems it's a big mess.

Reply by email

Daniël Mantione
to Jonas Maebe

Op Tue, 14 Nov 2006, schreef Jonas Maebe:

Show quoted text 7 lines
On 14 Nov 2006, at 22:04, Den Jean wrote: > so that binary compatibility with frequently used > bitmasks in C APIs is easier Aren't bitpacked records/arrays more appropriate for that?

Semantically speaking, no.

Daniël

Reply by email

Jonas Maebe
to Daniël Mantione
Daniël Mantione wrote 10 lines
Op Tue, 14 Nov 2006, schreef Jonas Maebe: > On 14 Nov 2006, at 22:04, Den Jean wrote: > >> so that binary compatibility with frequently used >> bitmasks in C APIs is easier > > Aren't bitpacked records/arrays more appropriate for that? Semantically speaking, no.

Sorry, I misread "bitmasks" as "bitfields". But using sets for C bitmasks is very dangerous, since sets are opaque and can differ from platform to platform (in practice only for endianess currently). It's the same for bitpacked arrays, in fact. Only bitfields in bitpacked records are identical as in C if combined with {$packrecords C}

Jonas

Reply by email