Go Back   ZeroC Forums > Comments

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 03-05-2003
dthomson dthomson is offline
Registered User
 
 
Join Date: Feb 2003
Location: Brisbane, Australia
Posts: 34
Question Why reserve *all* words beginning with "Ice"?

From the Ice documentation, section 4.5.3 "Identifiers":

Quote:
Reserved Identifiers

Slice reserves the identifier Ice and all identifiers beginning with Ice for the Ice implementation. For example, if you try to define a type named Icecream , the Slice compiler will issue an error message.
First question ... why reserve *all* words starting with "Ice"? That seems a little restrictive.

Secondly, why does it apply to nested scopes? For example, say I was designing a distributed version of a popular arcade game from 1982:

Code:
module Pengo
{
   struct Position
   {
       short x;
       short y;
   };

   interface Block
   {
     Position getPos();
   };

   interface Ice extends Block // Ouch!! This won't work!
   {
     void smash();
   };

   interface Penguin
   {
     void moveUp();
     void moveDown();
     void moveLeft();
     void moveRigth();
   };
};
Pengo::Ice is invalid Even Pengo::IceCube is not permitted. The idea of modules is to partition off different scopes, so it could be irritating that I'm forbidden to use certain names in my *own* scopes! Especially as Ice is a common English word.

However, I'm confident there's a good reason, but I just can't think of it ... something to do with the generated code, perhaps?
Reply With Quote
  #2 (permalink)  
Old 03-05-2003
michi's Avatar
michi michi is offline
ZeroC Staff
 
Name: Michi Henning
Organization: ZeroC
Project: Ice
 
Join Date: Feb 2003
Location: Brisbane, Australia
Posts: 896
Re: Why reserve *all* words beginning with "Ice"?

Quote:
Originally posted by dthomson


First question ... why reserve *all* words starting with "Ice"? That seems a little restrictive.

Secondly, why does it apply to nested scopes?
Ice is a reserved prefix to create a naming scope that we can safely use for internal purposes. For example, Ice is a module at the global level. If we were to allow you to define an identifier Ice at the global level, we get a clash.

We applied the rule to identifiers in nested scopes because, again, it allows us to use Ice as a prefix for generated identifiers. This is a problem in general: if a mapping generates new identifiers that are not present in the Slice definition, those identifiers must be generated into a separate namespace, otherwise they can clash with other legitimate identifiers. For an example, try compiling the code generated by an IDL-to-C++ compiler for CORBA if the IDL contains interface foo and interface foo_var. The IDL is valid, but the generated code cannot possibly compile.

So, in the end, we decided that Ice was going to be our universal escape hatch for such cases.

Note that you can use ice without any problems -- only Ice is reserved.

So, if you really want to implement Pengo, I'm afraid that you will have to use ice, ICE, or, if you like, FrozenWater

Cheers,

Michi.
Reply With Quote
  #3 (permalink)  
Old 03-05-2003
michi's Avatar
michi michi is offline
ZeroC Staff
 
Name: Michi Henning
Organization: ZeroC
Project: Ice
 
Join Date: Feb 2003
Location: Brisbane, Australia
Posts: 896
Re: Re: Why reserve *all* words beginning with "Ice"?

Quote:
Originally posted by michi

So, if you really want to implement Pengo, I'm afraid that you will have to use ice, ICE, or, if you like, FrozenWater
Hmmm... Actually, this is even more draconian contrary to what I said earlier. Because of the case-insensitive nature of Slice identifiers, we actually outlaw all identifiers that start with Ice, no matter how it is capitalized. This protects us if we want to map to languages such as FORTRAN, which is case-insensitive.

Derek, I'm afraid you are down to FrozenWater

Cheers,

Michi.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Don't "Ice-3.1.1-VC71.msi " include the "slice2java.exe"? Jason Gao Help Center 4 10-26-2006 11:23 AM
Icepack registry "TimeOut" exception with heavy load eaglecn Help Center 1 05-26-2006 12:02 AM
"Invalid UTF8 string" when transer chinese chars between cpp server and csharp client raygo Help Center 8 03-21-2006 08:34 PM
starting "ice" process (node/admin etc) via Java BobDeAnna Help Center 6 01-04-2005 09:26 AM
Going from "in" to "out" param, using a class as a union catalin Help Center 1 04-05-2004 08:55 AM


All times are GMT -4. The time now is 07:28 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.