LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-24-2004, 02:34 AM   #1
ananthbv
Member
 
Registered: Nov 2003
Posts: 49

Rep: Reputation: 15
pascal questions


hi all, i was going through some pascal programs. i could not make out some of these things

Code:
1. TYPE
           abc = crunched set of 0..15;

2. def := [0..15];
can someone explain me what they mean or where i can read up on them on the net? extremely helpful for any help.
 
Old 09-24-2004, 07:32 AM   #2
N43
LQ Newbie
 
Registered: Sep 2004
Location: Germany
Distribution: Slackware
Posts: 13

Rep: Reputation: 0
A set is a collection of the same ordinal type. You define a new range for sets with
Code:
type abc = set of 0..15
II have never seen it with the parameter crunched for Object Pascal. Maybe it is allowed in Free Pascal. With the following code you can assign a new 'set variable'.
Code:
var
   MySet: abc;
   //or
   MySet2: set of 0..15;
You can change the range during runtime.
Code:
MySet := [0..5]
The in operator is for checking wether ie. a number is in the set.
Code:
if 10 in MySet then
   Write('MySet includes 10');
Hope that helps.

N43
 
Old 09-24-2004, 04:26 PM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
An excerpt from this site explains 'crunched' records and which pascal versions have this extension to 'PACKED'.

http://www.allegro.com/papers/htpp.html

#1-36. "Crunched" records should be avoided unless the need for tight packing of the fields overrides the performance loss they cause.

Pascal/iX supports "crunched record", an extension beyond a simple "packed record". In a crunched record, there are *no* unused bits. If you declare a crunched record with a 1 bit field, followed by an 8 bit field, followed by a 1 bit field, then the entire record will occupy 10 bits, and the 8-bit field will require extra code to load/store.
 
Old 09-25-2004, 01:31 AM   #4
ananthbv
Member
 
Registered: Nov 2003
Posts: 49

Original Poster
Rep: Reputation: 15
thnks N43 and jschiwal for the explanation and the great link. so are sets just like C's bitfields?
 
Old 10-05-2004, 04:51 AM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
Sets are like an array of an enumerated type.

A bit field allows you to pack more than one field of a record into a storage unit. Such as having two 4-bit variables stored in a byte. However the possible values of the variables are not limited.

With a set, you could have a set where the lowest possible value is 3 and the highest possible value is 12. With a 4-bit bitfield, any value between 0 and 15 are possible.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can someone help me with Pascal? randyriver10 Programming 2 09-29-2005 04:09 PM
C++ and Pascal Compiler LinuxSeeker Linux - Software 2 06-19-2005 12:24 PM
Pascal For LINUX asoare13 Linux - Software 1 11-02-2004 03:14 AM
Pascal, and GTK Gerardoj Linux - General 1 09-23-2003 09:34 PM
GUI pascal nivek Programming 1 03-11-2003 08:13 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration