From: Patrick M D. <pa...@wa...> - 2001-10-07 01:52:13
|
I've been working on e-mail address support today and have a couple of suggestions: - I think it may be good to factor out the address support to a Netaddress module. It seems to distract from the focus of the Netmessage module. - Object-based representations for addresses may not be the best idea. I forgot that they don't support equality, which makes it impossible to use them as keys and it also complicates testing. I would recommend switching back to a record based structure: type mailbox = { name: string option; route: string list; spec: addr_spec; } type t = [ `Mailbox of mailbox | `Group of string * mailbox list ] Patrick |
From: Gerd S. <in...@ge...> - 2001-10-07 20:56:28
|
On Sun, 07 Oct 2001, Patrick M Doane wrote: >I've been working on e-mail address support today and have a couple >of suggestions: > > - I think it may be good to factor out the address support to > a Netaddress module. It seems to distract from the focus of the > Netmessage module. Agreed. This is another fundamental structure like Netdate. > - Object-based representations for addresses may not be the best idea. > I forgot that they don't support equality, which makes it impossible > to use them as keys and it also complicates testing. You can use objects as keys. The object ID is used in this case. I.e. obj1 = obj2 <=> obj1 and obj2 are the same object. Of course, objects are not compared component by component. I think the comparison by components does not make sense because there is no way to find out whether two mailbox references mean the same mailbox or not. Maybe the object ID is better. But I am undecided. Testing: It is possible to define printers for objects. >I would > recommend switching back to a record based structure: > > type mailbox = { > name: string option; > route: string list; > spec: addr_spec; > } Better: mb_name, mb_route, mb_spec. This avoids name clashes. > type t = > [ `Mailbox of mailbox > | `Group of string * mailbox list > ] > >Patrick Gerd -- ---------------------------------------------------------------------------- Gerd Stolpmann Telefon: +49 6151 997705 (privat) Viktoriastr. 45 64293 Darmstadt EMail: ge...@ge... Germany ---------------------------------------------------------------------------- |
From: Patrick M D. <pa...@wa...> - 2001-10-07 23:43:15
|
On Sun, 7 Oct 2001, Gerd Stolpmann wrote: > You can use objects as keys. The object ID is used in this case. I.e. > obj1 = obj2 <=> obj1 and obj2 are the same object. Of course, objects are not > compared component by component. > > I think the comparison by components does not make sense because there is no > way to find out whether two mailbox references mean the same mailbox or not. > Maybe the object ID is better. But I am undecided. > > Testing: It is possible to define printers for objects. I forgot that objects could check for equality on themselves. This does make the objects reasonable to deal with, with only a little more work for testing. In that case, I think I favor the object approach because of the ease of extensibility in the future For consistency with the message structures, there should be a method to access the original string for the address. I'm not sure how this should behave in the presence of mutability, or for addresses that are created programatically. One issue to consider is that there are many obsolete forms of addresses that must be supported for backwards compatibility, but must not be generated by new programs. Any suggestions? One option is to provide a validate method, another could be to have the printer simply ignore certain informate (like the route). > > type mailbox = { > > name: string option; > > route: string list; > > spec: addr_spec; > > } > > Better: mb_name, mb_route, mb_spec. This avoids name clashes. There are definitely two camps to this in the Caml community. I find myself opening the Unix module because the name fields have been prefixed. On the other hand, I probably wouldn't open the module if I didn't have to duplicate prefix information. Being able to avoid this issue is a definite benefit of the object system. Patrick |
From: Patrick M D. <pa...@wa...> - 2001-10-09 03:57:17
|
On Sun, 7 Oct 2001, Gerd Stolpmann wrote: > On Sun, 07 Oct 2001, Patrick M Doane wrote: > >I've been working on e-mail address support today and have a couple > >of suggestions: > > > > - I think it may be good to factor out the address support to > > a Netaddress module. It seems to distract from the focus of the > > Netmessage module. > > Agreed. This is another fundamental structure like Netdate. The simplest possible API has been checked in for Netaddress along with a parsing function I had from earlier work. I've added test cases based on examples from RFC 822, RFC 2822, and the real world. Patrick |