comp.lang.ada
 help / color / mirror / Atom feed
From: Mart van de Wege <mvdwege@mail.com>
Subject: Re: Single element arrays as function parameters
Date: Fri, 10 Jun 2011 23:28:26 +0200
Date: 2011-06-10T23:28:26+02:00	[thread overview]
Message-ID: <86aadpv0jp.fsf@gareth.avalon.lan> (raw)
In-Reply-To: isu0aj$216$1@dont-email.me

"J-P. Rosen" <rosen@adalog.fr> writes:

> Le 10/06/2011 22:11, Mart van de Wege a écrit :
>
>> M := Init.Creature( Name => "Dwarf",
>>    		       Creature_Type => Humanoid,
>>    		       Creature_Subtype => (Dwarf) );
>> 
>> The above call fails to compile:
>> 
>> test_create.adb:13:45: positional aggregate cannot have one component
> This is the clue: it is interpreted as a parenthesized value, not as an
> aggregate. Just write:
>
>  M := Init.Creature( Name => "Dwarf",
>     		       Creature_Type => Humanoid,
>     		       Creature_Subtype => (1 => Dwarf) );

Brrr. That works, but it looks a bit...ugly. Especially considering that
creatures only having one subtype[1] is the norm in Dungeons&Dragons
(the application in question is meant to help manage large amounts of
data to assist in running a campaign).

If there is no more elegant solution, I'll fix this by adding the
necessary remarks to the API description, in the unlikely case that
someone else except me is ever interested in this application.

Mart

[1] Side note: automating D&D in Ada is a pain, given the amount of
overlap between game terms and Ada keywords: Character, Class, Type,
Subtype...

-- 
"We will need a longer wall when the revolution comes."
    --- AJS, quoting an uncertain source.



  reply	other threads:[~2011-06-10 21:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-10 20:11 Single element arrays as function parameters Mart van de Wege
2011-06-10 20:54 ` J-P. Rosen
2011-06-10 21:28   ` Mart van de Wege [this message]
2011-06-10 21:58     ` Adam Beneschan
2011-06-10 22:24       ` Mart van de Wege
2011-06-11 12:28 ` Peter C. Chapin
2011-06-13 14:49   ` Adam Beneschan
replies disabled

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