|
From: Pascal Obry on 5 Apr 2008 08:14 Gautier, > function S (Source : Ada.Strings.Unbounded.Unbounded_String) return > String > renames Ada.Strings.Unbounded.To_String; > function U (Source : String) return > Ada.Strings.Unbounded.Unbounded_String > renames Ada.Strings.Unbounded.To_Unbounded_String; I'm doing the same with operator "+" and "-", but I'm not happy with that. You do not need the parenthesis with operators: external_packer: array(External) of Unbounded_String:= ( +"zip.exe", +"7z.exe", +"kzip.exe"); Better than nothing... Pascal. -- --|------------------------------------------------------ --| Pascal Obry Team-Ada Member --| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE --|------------------------------------------------------ --| http://www.obry.net --| "The best way to travel is by means of imagination" --| --| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595
From: Randy Brukardt on 5 Apr 2008 20:31 "Pascal Obry" <pascal(a)obry.net> wrote in message news:47F76D31.2090009(a)obry.net... > Gautier, > > > function S (Source : Ada.Strings.Unbounded.Unbounded_String) return > > String > > renames Ada.Strings.Unbounded.To_String; > > function U (Source : String) return > > Ada.Strings.Unbounded.Unbounded_String > > renames Ada.Strings.Unbounded.To_Unbounded_String; > > I'm doing the same with operator "+" and "-", but I'm not happy with > that. You do not need the parenthesis with operators: The only useful use for "+" in Ada is for conversions. So it is a common convention (I use it sometimes). We actually considered adding that rename to the strings packages, but enough people thought it was ugly that it wasn't done. (It needs getting used to, thus the hope of making the intent clearer by including it in the packages.) We also briefly considered adding an operator symbol specifically for this purpose. Something like function "#" (Source : String) return Unbounded_String; But the people who don't think "+" is ugly were against this, because we already have such an operator and thus don't need another one. Thus a deadlock. Sigh. > external_packer: array(External) of Unbounded_String:= > ( +"zip.exe", > +"7z.exe", > +"kzip.exe"); > > Better than nothing... I agree, and it doesn't look so ugly if you can think of unary "+" as the conversion operator. (Personally, I'd prefer a different symbol for this purpose, but "+" has the advantage of actually working now.) Randy.
From: Adam Beneschan on 7 Apr 2008 10:57 On Apr 5, 5:31 pm, "Randy Brukardt" <ra...(a)rrsoftware.com> wrote: > "Pascal Obry" <pas...(a)obry.net> wrote in message > > news:47F76D31.2090009(a)obry.net... > > > Gautier, > > > > function S (Source : Ada.Strings.Unbounded.Unbounded_String) return > > > String > > > renames Ada.Strings.Unbounded.To_String; > > > function U (Source : String) return > > > Ada.Strings.Unbounded.Unbounded_String > > > renames Ada.Strings.Unbounded.To_Unbounded_String; > > > I'm doing the same with operator "+" and "-", but I'm not happy with > > that. You do not need the parenthesis with operators: > > The only useful use for "+" in Ada is for conversions. Well, I can think of one other potentially useful use: with a numeric argument (especially a numeric literal, or something like pi). It doesn't have any effect but could serve to make things clearer in some mathematical cases. Maybe you'd call a bounded integration routine with +1.0 and -1.0 as the arguments. OK, so that's not much of a use. On the other hand, the idea that "+" represents the identity function is ingrained enough in me that I've resisted using it for a conversion operator even though others around me have been doing that. Call it an obstinate adherence to meaningless purity or whatever. But like Randy, I would have preferred adding one (maybe even two) operator symbols that would have no meaning except that the user could define them, although I'm not sure about "#" since that already has a use (in based numeric literals). I'd prefer something not currently used at all, like "@" or "!" or tilde. Of course, it apparently isn't going to happen anyway so there's not much point arguing about which character would be best. -- Adam
From: Dmitry A. Kazakov on 7 Apr 2008 11:23 On Mon, 7 Apr 2008 07:57:55 -0700 (PDT), Adam Beneschan wrote: > But like Randy, I would have > preferred adding one (maybe even two) operator symbols that would have > no meaning except that the user could define them, although I'm not > sure about "#" since that already has a use (in based numeric > literals). I'd prefer something not currently used at all, like "@" > or "!" or tilde. May I suggest Unicode Character 'NO-BREAK SPACE' (U+00A0)? Sorry, just could not resist (:-)) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de
From: stefan-lucks on 7 Apr 2008 12:34
> > The only useful use for "+" in Ada is for conversions. > > OK, so that's not much of a use. On the other hand, the idea that "+" > represents the identity function is ingrained enough in me that I've > resisted using it for a conversion operator even though others around > me have been doing that. Call it an obstinate adherence to > meaningless purity or whatever. But like Randy, I would have > preferred adding one (maybe even two) operator symbols that would have > no meaning except that the user could define them, although I'm not > sure about "#" since that already has a use (in based numeric > literals). I'd prefer something not currently used at all, like "@" > or "!" or tilde. Of course, it apparently isn't going to happen > anyway so there's not much point arguing about which character would > be best. Two natural candidates which come into my mind would be an unary '&' and the '%'-sign: '%' (percent) indicates some kind of conversion anyway (though usually in postfix notation, not as a prefix, "75 %" for 75/100). '&' is something you can even now use for conversion into strings and the like: declare an appropriate function function "&" (X: String; Y: Some_Type) return String; and then just write "" & A; wherever you need A being converted into a string. A unary "&" would be handy -- prepending the empty string clearly is artificial. So long Stefan -- ------ Stefan Lucks -- Bauhaus-University Weimar -- Germany ------ Stefan dot Lucks at uni minus weimar dot de ------ I love the taste of Cryptanalysis in the morning! ------ |