Computer Science Canada

record syntax.

Author:  Justin_ [ Wed Jan 18, 2006 6:43 pm ]
Post subject:  record syntax.

Hi, is there anything wrong with this code:

code:

type webData :
        record     %struct equivelant
            list_urls   : flexible array 1 .. 2 of string
            searchTerm  : string
            url_count   : int    %To determine how many links there are.
            lines       : string
            url         : string
            file_stream : flexible array 1 .. 2 of int
        end record


it says syntax error at "flexible"

Author:  Cervantes [ Wed Jan 18, 2006 6:54 pm ]
Post subject: 

Sadly, Turing can't handle flexible arrays within records. It's one of Turing's biggest problems, in my opinion.

The best you can do is declare a big hoinking static array ( Wink ) and use an index variable to keep track of the "upper" of it.

Author:  Justin_ [ Wed Jan 18, 2006 8:31 pm ]
Post subject: 

how unfortunate Crying or Very sad yeah the static array will have to do.

Author:  Tony [ Thu Jan 19, 2006 12:01 pm ]
Post subject: 

Cervantes wrote:
Sadly, Turing can't handle flexible arrays within records. It's one of Turing's biggest problems, in my opinion.

How would you go about implementing it? Suddenly you'll have a record type of arbitrary length. There will be a whole bunch of problems with reserving a correct amount of space and then adjusting it on per-record basis.

If you are dealing with a lot of data and do want to have it stored in a flexible array, you could declear it outside of the record definition, and point to it from within the record.

Author:  MysticVegeta [ Thu Jan 19, 2006 12:41 pm ]
Post subject: 

Well what you could have is a record inside a record.

Author:  codemage [ Thu Jan 19, 2006 1:41 pm ]
Post subject: 

Why jump through so many hoops to use a special Turing shortcut?

Flexible arrays are just a Turing-specific training-wheels-enabled version of dynamic lists.


: