comp.lang.ada
 help / color / mirror / Atom feed
From: Nick Roberts <nick.roberts@acm.org>
Subject: Re: Literate Programming in Ada, AdaDoc, AdaBrowse
Date: Sat, 09 Oct 2004 22:47:22 +0100
Date: 2004-10-09T22:47:22+01:00	[thread overview]
Message-ID: <2sr4jaF1od20uU1@uni-berlin.de> (raw)
In-Reply-To: <uwtxz3dfd.fsf@act-europe.fr>

Pascal Obry wrote:

> I'm just worried that the original source code instrumented with "--  "
> (unindented), "--+ " and "--- " plus the ${} macros would not be really easy
> to read. Do you have small example of an instrumented code ?

This is my idea of what the beginning of a package specification might look
like after being reformatted. I've not shown the expansion of "gmgpl.txt"
but I'm sure you can imagine the usual message.

~~~

-----------------------------------------------------------------------------------------------
-- {Titian.Color} package specification

-- Copyright (C) 2004 Nicholas James Roberts (South Croydon, Surrey, UK).

--+gmgpl.txt


-----------------------------------------------------------------------------------------------
-- =####= Color =####=

-- Titian uses a color system which accomodates the fact that many computer display systems can
-- only show a limited number of different colors at a time, whilst others can show an
-- unlimited number. For the former kind of display systems, the set of colors which can be
-- displayed is generally called a 'palette'. The latter display systems are often described
-- as 'true color' systems; the Titian term for them is that they have *'direct color'.

-- Titian ensures that the programmer has the choice of using direct color values or colors
-- selected from a palette, for all drawing operations. The former option will be slightly
-- more efficient for direct color contexts, and may be more convenient regardless of the
-- context. The latter option will be more efficient for contexts which do not have direct
-- color (but will be reasonably efficient for contexts that do). For maximum efficiency with
-- all possible contexts, the programmer could program two different algorithms for contexts
-- with and without direct color.

-- The basic color definitions are collected in this package ({Titian.Color}). Other
-- color-related packages are {Titian.Color.CMYK} and {Titian.Color.HSL}. The
-- color-related graphics context primitive operations are declared in the package
-- {Titian.Raster_IO}.

-- The term *'palette' is used for any set of distinct colors, as well as for the particular
-- set of colors associated with a graphics context.

-- Dealing with color in a way which will be suitable for the widest range of devices presents
-- bit of a challenge: different devices have widely varying ways of supporting color (e.g.
-- from those which have no colors at all, to video adapters which support a plethora of
-- different modes, each with its own combination of bit-planes, palette sizes, and so on). I
-- think there is a necessity to support the sophisticated color options many devices provide
-- - it would surely be a shame not to allow programs to take full advantage of them - but not
-- to the extent that overly complicates life for the poor beleaguered application programmer.
-- Furthermore, the facilities provided by the proposed binding for color manipulation must be
-- reasonably efficient. To this end, I have devised a system which hopefully allows
-- programmers the best of both worlds.

-- I hope the term direct color (defined just above) will be considered reasonably neutral.

-- I need help with the color systems. Also, I am completely in the dark as to the ins and
-- outs of color correction: I would appreciate help in this area.


-----------------------------------------------------------------------------------------------
with ???;


-----------------------------------------------------------------------------------------------
package Titian.Color is

   pragma Pure;


-----------------------------------------------------------------------------------------------
-- =###= The {Color_Error} Exception =###=

-- There is one color-related exception, {Color_Error}.

   Color_Error: exception;

-- The {Color_Error} exception is raised if:

-- * an attempt to engage a color in a palette fails (normally because the palette doesn't
-- have enough free slots);

-- * an attempt is made to use a color selector for an invalid slot (one which is neither
-- fixed nor has been engaged);

-- * an attempt is made to release fixed colors;

-- * a color conversion cannot be effected, either because the calculation would be too
-- difficult (or slow), or because the destination type cannot hold a color value
-- corresponding (closely enough) to the color being converted.


-----------------------------------------------------------------------------------------------
-- =###= Basic Color Descriptor =###=

-- The type {Basic_Color} holds color values in the familiar Red-Green-Blue, or *'RGB', system
-- of color representation, with the addition of an *'alpha value', which can be used to
-- control the extent to which the background of an image is allowed to show through. The RGB
-- system with alpha values can be termed the *'RGBA' color system.

   type Light_Level is delta 1.0/2**32 range 0.0 .. 1.0; -- implementation defined delta
   type Alpha_Level is delta 1.0/2**32 range 0.0 .. 1.0; -- implementation defined delta

   for Light_Level'Size use 32; -- implementation defined
   for Alpha_Level'Size use 32; -- implementation defined

   type Basic_Color is
      record
         Red, Green, Blue: Light_Level;
         Alpha: Alpha_Level := 1.0;
      end record;

   for Basic_Color'Size use 32*4; -- implementation defined

~~~

I think my idea for macro substitution (${...}) is not so clever, and
could be dropped. Maybe =###= could be used to delimit titles. Possibly
--- at the beginning of a line could be expanded to a line across. There
would have to be special logic to avoid trying to word-wrap lines
across! The lone * represents a bullet (for a list item). The form
*'foo' is intended to enter the word foo into a cross-index.

Obviously this is only a tiny example.

The syntax of the macros (if I keep them), would perhaps need to be
$LINE{...} where the ... is replaced by the correct value. The idea
behind the macros was so that you could write something like:

   if Error_Detected then
      Put_Line (Current_Error, "Error in $LINE{} $FILE{}");
   else
      ...

If the Put_Line happened to be on line 234 of the file "wibble.adb", then
the above would be expanded to:

   if Error_Detected then
      Put_Line (Current_Error, "Error in $LINE{234} $FILE{wibble.adb}");
   else
      ...

I'm not quite sure if this would be worth it.

-- 
Nick Roberts



  reply	other threads:[~2004-10-09 21:47 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-09 17:44 Literate Programming in Ada, AdaDoc, AdaBrowse Nick Roberts
2004-10-09 18:39 ` Wes Groleau
2004-10-09 21:04   ` Nick Roberts
2004-10-09 21:39     ` stephane richard
2004-10-09 23:40     ` Wes Groleau
2004-10-10 16:39     ` Simon Wright
2004-10-12  0:42       ` Georg Bauhaus
2004-10-11  7:33     ` Ole-Hjalmar Kristensen
2004-10-09 19:21 ` Pascal Obry
2004-10-09 21:47   ` Nick Roberts [this message]
2004-10-09 23:20     ` Björn Persson
2004-10-10  8:28       ` Oliver Kellogg
2004-10-10 10:03         ` Björn Persson
2004-10-10 15:27           ` Stephen Leake
2004-10-09 23:49     ` Wes Groleau
2004-10-10 10:36     ` Pascal Obry
2004-10-10 11:26       ` Marius Amado Alves
2004-10-18  8:17         ` Jacob Sparre Andersen
2004-10-18 11:15           ` Marius Amado Alves
2004-10-18 12:46             ` Björn Persson
2004-10-18 15:39               ` Marius Amado Alves
2004-10-18 13:47             ` Jacob Sparre Andersen
2004-10-09 22:54 ` Lionel Draghi
2004-10-09 22:56 ` Björn Persson
2004-10-09 23:55   ` Wes Groleau
2004-10-10  1:02     ` Björn Persson
2004-10-10 14:02       ` Wes Groleau
2004-10-10  3:29 ` Steve
2004-10-10 14:08   ` Wes Groleau
2004-10-10 15:06     ` Steve
2004-10-10 15:20   ` Stephen Leake
     [not found]   ` <rlsfz4jdjuj.fsf@jacob.crs4.it>
2004-10-15 13:33     ` Marius Amado Alves
2004-10-16  1:50     ` Steve
2004-10-16 19:46       ` Jacob Sparre Andersen
2004-10-17  3:46         ` Steve
2004-10-10  8:21 ` Stephane Riviere
2004-10-11 23:02   ` Björn Persson
2004-10-11 23:31     ` Missing features in NaturalAdaBrowseDoc Lionel Draghi
2004-10-12  0:14       ` tmoran
2004-10-12 12:58       ` Marc A. Criley
2004-10-12 21:20         ` Lionel Draghi
2004-10-12 17:49       ` Stephane Riviere
     [not found]         ` <416c48a7$0$28918$636a15ce@news.free.fr>
2004-10-12 21:18           ` Lionel Draghi
2004-10-13 16:38           ` Stephane Riviere
2004-10-14 19:56             ` Lionel Draghi
2004-10-15 16:59               ` Stephane Riviere
2004-10-12 17:29     ` Literate Programming in Ada, AdaDoc, AdaBrowse Stephane Riviere
2004-10-10  9:34 ` Andre
2004-10-10 15:24   ` Stephen Leake
2004-10-10 18:04     ` Andre
2004-10-11 23:32     ` Lionel Draghi
2004-10-12  0:13       ` Björn Persson
2004-10-10 15:13 ` Stephen Leake
2004-10-11 20:28 ` Nick Roberts
2004-10-11 22:26   ` Björn Persson
2004-10-12 14:09     ` Nick Roberts
2004-10-13  5:01       ` Pylinius
2004-10-13 16:06         ` Nick Roberts
2004-10-13 17:17     ` Pascal Obry
2004-10-17 18:47   ` Bernhard Mulder
2004-10-18 18:06     ` Nick Roberts
2004-10-19  4:41       ` Bernhard Mulder
2004-10-19  9:52         ` Peter Hermann
2004-10-19 10:01         ` Nick Roberts
2004-10-23 21:39           ` Bernhard Mulder
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox