[SAGA-RG] Semantics of the ns_entry constructor

Andre Merzky andre at merzky.net
Mon Aug 17 09:35:15 CDT 2009


Can of worms indeed...

A.


Quoting [Ceriel Jacobs] (Aug 17 2009):
> Date: Mon, 17 Aug 2009 15:54:15 +0200
> From: Ceriel Jacobs <ceriel at cs.vu.nl>
> To: Andre Merzky <andre at merzky.net>
> CC: Mathijs den Burger <mathijs at cs.vu.nl>, saga-rg at ogf.org
> Subject: Re: [SAGA-RG] Semantics of the ns_entry constructor
> 
> Andre Merzky wrote:
> >Quoting [Ceriel Jacobs] (Aug 17 2009):
> >>>If the above works, I don't see why 
> >>>
> >>> saga::file::entry e (u);
> >>>
> >>>should not work.  Or am I missing something?  The same then
> >>>also holds for the open methods - the origin of Matijs'
> >>>complain.
> >>It is a major semantics change. If you do that, all methods in the
> >>ns_entry implementations now have to consider the possibility that
> >>the entry in fact is a directory, whereas earlier they could just
> >>be hidden by ns_directory implementations.
> >
> >But yes, that is how it is supposed to work, IMHO.  For
> >example, the spec states what happens on entry.copy() if the
> >entry happens to be a directory.  And similar for other
> >calls on entry.
> 
> Yes, of course, but up until now, an implementation could do this by
> redefining f.i. the copy method in its ns_directory implementation.
> 
> >>Also, I think it is confusing
> >>that you can have a ns_entry object that represents a directory but cannot
> >>be casted to a ns_directory. Note that I don't have an issue with the
> >>change in the ns_directory.open method, only with the change in the 
> >>ns_entry
> >>constructor which, being a constructor, cannot deliver a ns_directory.
> >
> >No, it does not deliver an ns_directory.  The following
> >would *not* work:
> >
> >  saga::url u ("file://localhost/etc/");
> >  saga::file::dir * f = new saga::file::entry (u);
> >
> >That would be technically impossible I think.
> >But (again) the following should work:
> >
> >  saga::url u ("file://localhost/etc/");
> >  saga::file::entry * e = new saga::file::entry (u);
> >
> >I still don't see a reason why that should be invalid.
> 
> It WAS invalid, because the specs say so explicitly.
> 
> If an ns_entry can represent a directory, can a SAGA file object do so as 
> well?
> IMHO, the intention of ns_entry has clearly been that it does not represent
> a directory. For that, you have ns_directory. If you change that, what 
> should
> ns_directory.open() create when the requested entry does not exist?
> And what happens with directory.open()? Its notes refer to the
> ones from ns_directory.open(). So those are wrong as well?
> and logical_directory.open()?
> 
> >Matijs' use case seems very valid to me:
> >
> >  saga::url u ("file://localhost/etc/");
> >  saga::file::entry * e = new saga::file::entry (u);
> >
> >  if ( e->is_dir () )
> >  {
> >    saga::file::dir * f = new saga::file::directory (u);
> >  }
> 
> I agree that the use-case is valid, I just have the impression that
> allowing directories to be represented by ns_entry may open a can of
> worms in the SAGA specs ...
> 
> Also, the use case could be expressed differently:
> 
> saga::url u ("file://localhost/etc/");
> saga::file::entry *e;
> try {
>     e = new saga::file::entry (u);
> } catch(BadParameter ex) {
>     try {
>         e = new saga::file::directory (u);
>     } catch(Throwable ex2) {
>         ... deal with exception
>     }
> }
> 
> Ceriel



-- 
Nothing is ever easy.


More information about the saga-rg mailing list