Sign in Join

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

Mailing lists / fpc-pascal / 2003-05

Representing data

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Alan Mead

Tell me if this is not an appropriate question for this list.

I was thrilled to find out how mature FPC had become (thanks!) and I'm using Pascal again. But I find that I miss Perl's magical ability to handle different data types in scalars. Can I create an "datum" object that can gracefully hold different types of data?

I ask because I need to represent numeric data in memory and analyze it. The data will "look" like an Excel spreadsheet (and if I cannot fit it all in RAM I'll have to operate on it piece-meal). The values will be strings, reals, bytes and often large numbers of binary values. But one dataset might have one column of reals while another might have five columns of reals. One dataset might be composed almost entirely of binary values while another is composed of mostly bytes. How can I design code that handles any of these datatypes efficiently but without knowing in advance how much it will get? Execution speed, BTW, is far down on my list of priorities after robustness, flexibility, platform independence, maintaintainability, etc.

Thanks!

-Alan Mead

=====
A Congressman was once asked about his attitude toward whiskey. "If you mean the demon drink that poisons the mind, pollutes the body, desecrates family life, and inflames sinners, then I'm against it. "

"But if you mean the elixir of Christmas cheer, the shield against winter chill, the taxable potion that puts needed funds into public coffers to comfort little crippled children, then I'm for it."

"This is my position, and I will not compromise."

__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com

Reply by email

John Coppens
to Alan Mead

Hello, Alan

This is normally done in a more rigid language like Pascal by object oriented programming, and using polymorphism. You can then not only store different types of values into an object, but also define the correct actions that can be undertaken on each type.

Do a search on these terms, and you'll find plenty tutorials/texts on the subject.

John

Show quoted text 45 lines
Tell me if this is not an appropriate question for this list. I was thrilled to find out how mature FPC had become (thanks!) and I'm using Pascal again. But I find that I miss Perl's magical ability to handle different data types in scalars. Can I create an "datum" object that can gracefully hold different types of data? I ask because I need to represent numeric data in memory and analyze it. The data will "look" like an Excel spreadsheet (and if I cannot fit it all in RAM I'll have to operate on it piece-meal). The values will be strings, reals, bytes and often large numbers of binary values. But one dataset might have one column of reals while another might have five columns of reals. One dataset might be composed almost entirely of binary values while another is composed of mostly bytes. How can I design code that handles any of these datatypes efficiently but without knowing in advance how much it will get? Execution speed, BTW, is far down on my list of priorities after robustness, flexibility, platform independence, maintaintainability, etc. Thanks! -Alan Mead ===== A Congressman was once asked about his attitude toward whiskey. "If you mean the demon drink that poisons the mind, pollutes the body, desecrates family life, and inflames sinners, then I'm against it. " "But if you mean the elixir of Christmas cheer, the shield against winter chill, the taxable potion that puts needed funds into public coffers to comfort little crippled children, then I'm for it." "This is my position, and I will not compromise." __________________________________ Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo. http://search.yahoo.com _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email