comp.lang.ada
 help / color / mirror / Atom feed
* ICFP Programming Contest virtual machine in Ada
@ 2006-08-01  9:59 Samuel Tardieu
  2006-08-01 16:14 ` Hyman Rosen
  2006-08-01 20:43 ` Georg Bauhaus
  0 siblings, 2 replies; 19+ messages in thread
From: Samuel Tardieu @ 2006-08-01  9:59 UTC (permalink / raw)


Just for the fun, I posted my Ada implementation of the virtual
machine needed to run the ICFP Programming Contest 2006.

See http://www.rfc1149.net/blog/2006/08/01/icfp-ada-virtual-machine/

  Sam
-- 
Samuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: ICFP Programming Contest virtual machine in Ada
  2006-08-01  9:59 ICFP Programming Contest virtual machine in Ada Samuel Tardieu
@ 2006-08-01 16:14 ` Hyman Rosen
  2006-08-01 18:53   ` Samuel Tardieu
  2006-08-01 20:43 ` Georg Bauhaus
  1 sibling, 1 reply; 19+ messages in thread
From: Hyman Rosen @ 2006-08-01 16:14 UTC (permalink / raw)


Samuel Tardieu wrote:
> Just for the fun, I posted my Ada implementation of the virtual
> machine needed to run the ICFP Programming Contest 2006.

Did you verify whether it works properly on systems where text
and binary I/O are different? In the contest, the first thing the
machine needs to do is "decompress" a file, and both the input
and output contain sequences which will be mangled if the normal
text CR LF mapping takes place. I ran afoul of that in my C++
version of the code and it took me a while to realize what was
going on.




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: ICFP Programming Contest virtual machine in Ada
  2006-08-01 16:14 ` Hyman Rosen
@ 2006-08-01 18:53   ` Samuel Tardieu
  2006-08-01 20:33     ` Hyman Rosen
  0 siblings, 1 reply; 19+ messages in thread
From: Samuel Tardieu @ 2006-08-01 18:53 UTC (permalink / raw)


>>>>> "Hyman" == Hyman Rosen <hyman.rosen@gmail.com> writes:

Hyman> Did you verify whether it works properly on systems where text
Hyman> and binary I/O are different? In the contest, the first thing
Hyman> the machine needs to do is "decompress" a file, and both the
Hyman> input and output contain sequences which will be mangled if the
Hyman> normal text CR LF mapping takes place. I ran afoul of that in
Hyman> my C++ version of the code and it took me a while to realize
Hyman> what was going on.

As you can see in the code, I used Stream_IO, which only considers raw
bytes, so this is not an issue.

  Sam
-- 
Samuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: ICFP Programming Contest virtual machine in Ada
  2006-08-01 18:53   ` Samuel Tardieu
@ 2006-08-01 20:33     ` Hyman Rosen
  2006-08-01 23:29       ` Samuel Tardieu
  0 siblings, 1 reply; 19+ messages in thread
From: Hyman Rosen @ 2006-08-01 20:33 UTC (permalink / raw)


Samuel Tardieu wrote:
> As you can see in the code, I used Stream_IO, which only considers raw
> bytes, so this is not an issue.

I don't know Ada, so pardon me if I'm saying something
obviously wrong. Your code has
    when 10 => Put (Character'Val (Regs (C))); Flush;

Is this Stream_IO or regular text IO? The contest has you
download a binary file called codex.umz. When you register,
you receive a "decompression key". When you run the machine
against codex.umz, it eventually asks you for the key, then it
goes into interactive mode. In that mode, you are asked to enter
'p', and when you do, the machine spits out the "decompressed"
form of the codex using these opcode 10 put operands. This output
needs to be captured and slightly edited to remove a header, and
then the machine needs to be rerun on this output. If your Put is
text and not binary, the output will be garbled, assuming that Ada's
text Put does the usual LF => CR LF mapping.




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: ICFP Programming Contest virtual machine in Ada
  2006-08-01  9:59 ICFP Programming Contest virtual machine in Ada Samuel Tardieu
  2006-08-01 16:14 ` Hyman Rosen
@ 2006-08-01 20:43 ` Georg Bauhaus
  2006-08-01 21:22   ` Alex Buell
                     ` (3 more replies)
  1 sibling, 4 replies; 19+ messages in thread
From: Georg Bauhaus @ 2006-08-01 20:43 UTC (permalink / raw)


On Tue, 2006-08-01 at 11:59 +0200, Samuel Tardieu wrote:
> Just for the fun, I posted my Ada implementation of the virtual
> machine needed to run the ICFP Programming Contest 2006.
> 
> See http://www.rfc1149.net/blog/2006/08/01/icfp-ada-virtual-machine/

Alas, this code cannot be compiled with a plain Ada compiler
as it uses non-Ada 'Img (which is brief, though).


-- Georg 





^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: ICFP Programming Contest virtual machine in Ada
  2006-08-01 20:43 ` Georg Bauhaus
@ 2006-08-01 21:22   ` Alex Buell
  2006-08-01 23:28   ` Javier Miranda
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 19+ messages in thread
From: Alex Buell @ 2006-08-01 21:22 UTC (permalink / raw)


On Tue, 01 Aug 2006 22:43:23 +0200, I waved a wand and this message
magically appeared from Georg Bauhaus:

> > See http://www.rfc1149.net/blog/2006/08/01/icfp-ada-virtual-machine/
> 
> Alas, this code cannot be compiled with a plain Ada compiler
> as it uses non-Ada 'Img (which is brief, though).

Compiles just fine with GNAT ADA. 
-- 
http://www.munted.org.uk

Take a nap, it saves lives.



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: ICFP Programming Contest virtual machine in Ada
  2006-08-01 20:43 ` Georg Bauhaus
  2006-08-01 21:22   ` Alex Buell
@ 2006-08-01 23:28   ` Javier Miranda
  2006-08-02  9:13     ` Georg Bauhaus
  2006-08-01 23:47   ` Samuel Tardieu
  2006-08-02  5:13   ` Gautier
  3 siblings, 1 reply; 19+ messages in thread
From: Javier Miranda @ 2006-08-01 23:28 UTC (permalink / raw)
  To: Georg Bauhaus; +Cc: comp.lang.ada


On Aug 1, 2006, at 4:43 PM, Georg Bauhaus wrote:

> Alas, this code cannot be compiled with a plain Ada compiler
> as it uses non-Ada 'Img (which is brief, though).

Considering T the type of the object to which you apply this
attribute, this is a GNAT attribute that is equivalent to
T'Image (Obj).

For example, being V a variable containing an integer value,
instead of writing Integer'Image (V) you can just write V'Img.

Regards,

---- Javier Miranda



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: ICFP Programming Contest virtual machine in Ada
  2006-08-01 20:33     ` Hyman Rosen
@ 2006-08-01 23:29       ` Samuel Tardieu
  0 siblings, 0 replies; 19+ messages in thread
From: Samuel Tardieu @ 2006-08-01 23:29 UTC (permalink / raw)


>>>>> "Hyman" == Hyman Rosen <hyman.rosen@gmail.com> writes:

Hyman> If your Put is text and not binary, the output will be garbled,
Hyman> assuming that Ada's text Put does the usual LF => CR LF
Hyman> mapping.

It doesn't. If you want the mapping, you have to use the New_Line
procedure (or Put_Line which combines both). And yes, it works fine to
get the second codex :)

  Sam
-- 
Samuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: ICFP Programming Contest virtual machine in Ada
  2006-08-01 20:43 ` Georg Bauhaus
  2006-08-01 21:22   ` Alex Buell
  2006-08-01 23:28   ` Javier Miranda
@ 2006-08-01 23:47   ` Samuel Tardieu
  2006-08-02  5:13   ` Gautier
  3 siblings, 0 replies; 19+ messages in thread
From: Samuel Tardieu @ 2006-08-01 23:47 UTC (permalink / raw)


>>>>> "Georg" == Georg Bauhaus <bauhaus@futureapps.de> writes:

Georg> Alas, this code cannot be compiled with a plain Ada compiler as
Georg> it uses non-Ada 'Img (which is brief, though).

I've removed the whole exception block. I had put it there just in
case but it was never triggered anyway (as no exception except
End_Of_Program will be raised by a conforming program).

  Sam
-- 
Samuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: ICFP Programming Contest virtual machine in Ada
  2006-08-01 20:43 ` Georg Bauhaus
                     ` (2 preceding siblings ...)
  2006-08-01 23:47   ` Samuel Tardieu
@ 2006-08-02  5:13   ` Gautier
  2006-08-02  9:36     ` Samuel Tardieu
  2006-08-03 22:58     ` Keith Thompson
  3 siblings, 2 replies; 19+ messages in thread
From: Gautier @ 2006-08-02  5:13 UTC (permalink / raw)


Georg Bauhaus:

> Alas, this code cannot be compiled with a plain Ada compiler
> as it uses non-Ada 'Img (which is brief, though).

Yep, the golden rule is: before releasing, always test with two 
different compilers, you never know. For instance, the Aonix ObjectAda 
one... A download of the 7.2.2 SE can be found there:
   http://www.ada-deutschland.de/AdaTourCD2004/index_tools.html
Probabily a newer version can be found on Aonix's site.
_______________________________________________________________
Gautier         -- http://www.mysunrise.ch/users/gdm/index.htm
Ada programming -- http://www.mysunrise.ch/users/gdm/gsoft.htm

NB: For a direct answer, e-mail address on the Web site!



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: ICFP Programming Contest virtual machine in Ada
  2006-08-01 23:28   ` Javier Miranda
@ 2006-08-02  9:13     ` Georg Bauhaus
  2006-08-02 10:29       ` Javier Miranda
       [not found]       ` <2BEFF609-48F1-4420-8A24-ECFCB5BAD1E3@iuma.ulpgc.es>
  0 siblings, 2 replies; 19+ messages in thread
From: Georg Bauhaus @ 2006-08-02  9:13 UTC (permalink / raw)


Javier Miranda wrote:
> 
> On Aug 1, 2006, at 4:43 PM, Georg Bauhaus wrote:
> 
>> Alas, this code cannot be compiled with a plain Ada compiler
>> as it uses non-Ada 'Img (which is brief, though).
> 
> Considering T the type of the object to which you apply this
> attribute, this is a GNAT attribute that is equivalent to
> T'Image (Obj).

Yes, but 'Img was invented for quickly writing debugging
expressions, IIRC, not for writing standard Ada expressions.

It might be worth pointing out that T must be a scalar type.

> For example, being V a variable containing an integer value,
> instead of writing Integer'Image (V) you can just write V'Img.

No, you can't write V'Img because 'Img is a GNAT implementation
defined attribute ;-) For a standard Ada program, you must write
Integer'Image(V).

Pragma Extensions_Allowed(Off) does not seem to turn this 'Img
extension of. Is there a switch to instruct gnatmake to warn
about implementation defined attributes? Or more generally,
something with an intent similar to -gnato, or -gnat83/95/05,
that makes GNAT reject non-standard constructs? 

(I have found some advice in the GNAT documentation
to not use implementation defined pragmas when portability
is an issue; given the qualities of GNAT, I should think that
it can categorize the pragmas found in source text, and inform
about the result.)


-- Georg 






^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: ICFP Programming Contest virtual machine in Ada
  2006-08-02  5:13   ` Gautier
@ 2006-08-02  9:36     ` Samuel Tardieu
  2006-08-02 20:39       ` tmoran
  2006-08-03  7:30       ` gautier_niouzes
  2006-08-03 22:58     ` Keith Thompson
  1 sibling, 2 replies; 19+ messages in thread
From: Samuel Tardieu @ 2006-08-02  9:36 UTC (permalink / raw)


>>>>> "Gautier" == Gautier  <gautier@fakeaddress.nil> writes:

Gautier> Yep, the golden rule is: before releasing, always test with
Gautier> two different compilers, you never know.

What are those two other compilers available as Free Software? (I
don't install random binaries on my computer, even if they are gratis)

  Sam
-- 
Samuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: ICFP Programming Contest virtual machine in Ada
  2006-08-02  9:13     ` Georg Bauhaus
@ 2006-08-02 10:29       ` Javier Miranda
       [not found]       ` <2BEFF609-48F1-4420-8A24-ECFCB5BAD1E3@iuma.ulpgc.es>
  1 sibling, 0 replies; 19+ messages in thread
From: Javier Miranda @ 2006-08-02 10:29 UTC (permalink / raw)
  To: Georg Bauhaus; +Cc: comp.lang.ada


On Aug 2, 2006, at 5:13 AM, Georg Bauhaus wrote:

> Pragma Extensions_Allowed(Off) does not seem to turn this 'Img
> extension of.

I take note to fix this problem.

> (I have found some advice in the GNAT documentation
> to not use implementation defined pragmas when portability
> is an issue; given the qualities of GNAT, I should think that
> it can categorize the pragmas found in source text, and inform
> about the result.)

That's a nice enhancement (I also take note of it). Currently
the main goal is to complete the implementation of Ada 2005.
Enhancements will have their time later ;-)

--- Javier Miranda



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: ICFP Programming Contest virtual machine in Ada
       [not found]       ` <2BEFF609-48F1-4420-8A24-ECFCB5BAD1E3@iuma.ulpgc.es>
@ 2006-08-02 12:39         ` Javier Miranda
  2006-08-02 13:57           ` Georg Bauhaus
  0 siblings, 1 reply; 19+ messages in thread
From: Javier Miranda @ 2006-08-02 12:39 UTC (permalink / raw)
  To: Georg Bauhaus, comp.lang.ada


On Aug 2, 2006, at 6:29 AM, Javier Miranda wrote:

> On Aug 2, 2006, at 5:13 AM, Georg Bauhaus wrote:
>
>> Pragma Extensions_Allowed(Off) does not seem to turn this 'Img
>> extension of.
>
> I take note to fix this problem.

There is no need to fix anything. There is standard support for this
feature in Ada 2005 and already supported by GNAT:

http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00257.TXT?rev=1.8

Regards,

--- Javier Miranda






^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: ICFP Programming Contest virtual machine in Ada
  2006-08-02 12:39         ` Javier Miranda
@ 2006-08-02 13:57           ` Georg Bauhaus
  0 siblings, 0 replies; 19+ messages in thread
From: Georg Bauhaus @ 2006-08-02 13:57 UTC (permalink / raw)


On Wed, 2006-08-02 at 08:39 -0400, Javier Miranda wrote:
> On Aug 2, 2006, at 6:29 AM, Javier Miranda wrote:
> 
> > On Aug 2, 2006, at 5:13 AM, Georg Bauhaus wrote:
> >
> >> Pragma Extensions_Allowed(Off) does not seem to turn this 'Img
> >> extension of.
> >
> > I take note to fix this problem.
> 
> There is no need to fix anything. There is standard support for this
> feature in Ada 2005 and already supported by GNAT:
> 
> http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00257.TXT?rev=1.8

Excellent. Perhaps the GNAT Reference Manual and the User's Guide
could hint to the good news in

@chapter Implementation Defined Pragmas (third paragraph)
@chapter Implementation Defined Attributes (third paragraph)
and
@section Compatibility with Other Ada 95 Systems

respectively?


-- Georg 





^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: ICFP Programming Contest virtual machine in Ada
  2006-08-02  9:36     ` Samuel Tardieu
@ 2006-08-02 20:39       ` tmoran
  2006-08-03  7:30       ` gautier_niouzes
  1 sibling, 0 replies; 19+ messages in thread
From: tmoran @ 2006-08-02 20:39 UTC (permalink / raw)


> Gautier> Yep, the golden rule is: before releasing, always test with
> Gautier> two different compilers, you never know.
>
> What are those two other compilers available as Free Software?
   The alternative to installing a compiler for a language
(legitimate Ada, in this case), is to hand-compile your program.



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: ICFP Programming Contest virtual machine in Ada
  2006-08-02  9:36     ` Samuel Tardieu
  2006-08-02 20:39       ` tmoran
@ 2006-08-03  7:30       ` gautier_niouzes
  2006-08-03 13:36         ` Samuel Tardieu
  1 sibling, 1 reply; 19+ messages in thread
From: gautier_niouzes @ 2006-08-03  7:30 UTC (permalink / raw)


Samuel Tardieu:

> What are those two other compilers available as Free Software? (I
> don't install random binaries on my computer, even if they are gratis)

You mean, on the Web site ? I see only one (other than GNAT) there:
ObjectAda.

G.




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: ICFP Programming Contest virtual machine in Ada
  2006-08-03  7:30       ` gautier_niouzes
@ 2006-08-03 13:36         ` Samuel Tardieu
  0 siblings, 0 replies; 19+ messages in thread
From: Samuel Tardieu @ 2006-08-03 13:36 UTC (permalink / raw)


>>>>> "Gautier" == gautier niouzes <gautier_niouzes@hotmail.com> writes:

Gautier> Samuel Tardieu:
>> What are those two other compilers available as Free Software? (I
>> don't install random binaries on my computer, even if they are
>> gratis)

Gautier> You mean, on the Web site ? I see only one (other than GNAT)
Gautier> there: ObjectAda.

ObjectAda is not Free Software.

  Sam
-- 
Samuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: ICFP Programming Contest virtual machine in Ada
  2006-08-02  5:13   ` Gautier
  2006-08-02  9:36     ` Samuel Tardieu
@ 2006-08-03 22:58     ` Keith Thompson
  1 sibling, 0 replies; 19+ messages in thread
From: Keith Thompson @ 2006-08-03 22:58 UTC (permalink / raw)


Gautier <gautier@fakeaddress.nil> writes:
> Georg Bauhaus:
>> Alas, this code cannot be compiled with a plain Ada compiler
>> as it uses non-Ada 'Img (which is brief, though).
>
> Yep, the golden rule is: before releasing, always test with two
> different compilers, you never know. For instance, the Aonix ObjectAda
> one... A download of the 7.2.2 SE can be found there:
>    http://www.ada-deutschland.de/AdaTourCD2004/index_tools.html
> Probabily a newer version can be found on Aonix's site.

Here's an English translation, via Babel Fish, of the web site's
description for the ObjectAda download:

    ObjectAda (R) for Windows (R) Special edition License

    ObjectAda is a family of integrated development environments for
    the production of portable, reliable and efficient programs.
    ObjectAda is available on the platforms Windows, Solaris, HP-UX
    and AIX. ObjectAda real-time supports the processor families power
    PC, Intel and Motorola 68k as CROSS development platform.

    The Special edition of ObjectAda for Windows is not a fully
    functional version of ObjectAda and requires a license key. It may
    not be used for commercial purposes. The following restrictions
    apply: a program may not contain any more than 35 translation
    units. A translation unit may not contain again no more as 20
    tasks and no more than 2000 lines.
    (Setup implement.)

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst>
We must do something.  This is something.  Therefore, we must do this.



^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2006-08-03 22:58 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-01  9:59 ICFP Programming Contest virtual machine in Ada Samuel Tardieu
2006-08-01 16:14 ` Hyman Rosen
2006-08-01 18:53   ` Samuel Tardieu
2006-08-01 20:33     ` Hyman Rosen
2006-08-01 23:29       ` Samuel Tardieu
2006-08-01 20:43 ` Georg Bauhaus
2006-08-01 21:22   ` Alex Buell
2006-08-01 23:28   ` Javier Miranda
2006-08-02  9:13     ` Georg Bauhaus
2006-08-02 10:29       ` Javier Miranda
     [not found]       ` <2BEFF609-48F1-4420-8A24-ECFCB5BAD1E3@iuma.ulpgc.es>
2006-08-02 12:39         ` Javier Miranda
2006-08-02 13:57           ` Georg Bauhaus
2006-08-01 23:47   ` Samuel Tardieu
2006-08-02  5:13   ` Gautier
2006-08-02  9:36     ` Samuel Tardieu
2006-08-02 20:39       ` tmoran
2006-08-03  7:30       ` gautier_niouzes
2006-08-03 13:36         ` Samuel Tardieu
2006-08-03 22:58     ` Keith Thompson

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