RejectedSoftware Forums

Sign up

Pages: 1 2 3 4

Re: Should packages be restricted to a single name space?

Not "want", I appreciate the positive properties, but the fact that even I am still running into walls and more special cases would need to be added, plus the other mentioned issues, could just be a sign that this restriction may just not be a good idea after all. I hope that you can wake up one day and suddenly you realize how these restrictions have just restrained your life up to that point ;)

:-) I can be quite stubborn, but I always try to understand the other side and I am very grateful that you took the time to explain your view of things to me and especially that you considered the proposal. I like clean concepts a lot, but obviously the D package = package assumption was too neat to be reality.

Well, in your case you also have to make sure that all packages adhere to the restrictions, you have to manage those :suffixes, implement all the new concepts like sub-packages first and whatnot. Just adding a list of D packages for each package record really is trivial and has the nice property that it can be done at a later point when needed for the scripting feature or when it shows that people create unwanted conflicts.

It is more work and less straight forward, but with a good infrastructure and the right tools it would not be too bad. I guess this is what computers are there for.

I totally disagree. This is far less work and much more straight forward. Try to list up all the things that are necessary to implement for your proposal. If you are careful, you'll see that there is actually a lot of work in it.

If you consider proper handling of circular dependencies and stuff, for packages that don't fit the scheme. Likely! This also was, what finally convinced me to drop it. I have to admit, that I am already in a position, that if you changed your mind now and say let's do it, I would say: "Are you sure? I think it is garbage."

It is simple, the core concept, it's fitting things into a model that they weren't made for that makes things complex.

I totally agree with that, as I already said, if the basic assumption of the proposal is not matched in reality, it is not worth the trouble.

Well, depending on the use case that may be the case, or may be not (you can only consider actual module clashes as a conflict, or you can already count package clashes as conflicts). Anyway, I fail to see the problem, even when capturing all modules.

Counting package clashes as conflicts does not work. Think of "org.eclipse.swt", most certainly another package should be allowed to use the "org" package or "org.eclipse" or even "org.eclipse.swt.something.not.in.the.base.dwt.package". Not even restricting the check to leaf packages (packages containing only modules) would be ok in all cases, if we think of C libraries that are made available via a single D module. But I agree, having to capture all modules is no real problem.

I have to think a bit more about the consequences of not implementing my proposal, but with the right infrastructure and tools available, most issues should be solvable. E.g. having an IDE showing me the containing package name when I hover over an import line, having a commit hook that calls dub with some parameter that checks for conflicts with the registry, ...

Sorry, but that's a totally unrealistic case you make up there. Please, show me where such conflicts happen in reality and we can talk about it, but constructing cases like this is just... after all we have concrete issues with the restricted case but still not one concrete example of issues with the unrestricted case (and there is a sheer unlimited set of examples in the world).

I don't exactly know what you are referring to? To the commit hook thing? I am just saying that one can set up something like that, if he wants to be on the safe side. But never mind, it is quite possible that I am taking this conflict stuff a bit to serious. If you refer to the first sentence about consequences, I was not thinking about conflicts in this case, but rather whether my original goals for a package manager can still be met. "Consequences" might have been a bit of a too hard word, what I wanted to say was: "I have to think everything through again on top of the changed semantics".

I hear you, I used to see that clean package tree right before my eyes :)

...but then reality came in and destroyed everything ;)

I am happy that I am not alone with this! ;)

Best regards,

Robert

Re: Should packages be restricted to a single name space?

I thought about warning just for leaves of the package tree, so e.g. those two would conflict:

somelib.subpack1
somelib.subpack2
somelib.subpack2
somelib.subpack3

But this one wouldn't

somelib.subpack1.subsubpack

What if somelib.subpack1 contained a module named subsubpack? Admittedly unlikely with those example names, but not necessarily in the general case. Also as mentioned in my other post, there are single modules which pull in a complete C library, in those cases it might make sense to actually pack a single module, sharing a D package with other modules/packages pulling in C libraries. Also the check for leaf packages is quite artificial: "Why do I have checks for my leaf packages, but not for my higher level sub packages?"


Another probably better idea would be to only include packages in the list that actually contain modules. That would be a more conservative approach, where it can still be guaranteed that there are no conflicts, but still it should be sufficiently flexible.

I thought of packages containing just modules as leaf packages. If you mean the sub packages of a library, you have the problem that if packages are not named after D packages, that it is not really obvious what those actually are, as not all packages might be installed top level. For example: "org.eclipse.swt" or "somecompany.lib1".

On a different matter, should we also warn about conflicts with -J files?

I tend to say no, because they have a defined override behavior and this is very useful to customize Diet templates of dependencies. A more explicit way would be desirable, but I don't know how that should work without uglifying the API.

How is it defined? I just tried, it seems it is the same as for -I, meaning the first that is specified wins. So dub will simply add the -J paths of direct dependencies before the ones of indirect dependencies?

About uglifying the API, I think if I needed to do this, I would just derive from implementing class and override the method instantiating the vibe template. Wouldn't this work?

But yeah, if this is common practice issuing warnings is useless at best.

Best regards,

Robert

Re: Should packages be restricted to a single name space?

On Tue, 12 Mar 2013 17:40:15 GMT, Robert wrote:

Well, depending on the use case that may be the case, or may be not (you can only consider actual module clashes as a conflict, or you can already count package clashes as conflicts). Anyway, I fail to see the problem, even when capturing all modules.

Counting package clashes as conflicts does not work. Think of "org.eclipse.swt", most certainly another package should be allowed to use the "org" package or "org.eclipse" or even "org.eclipse.swt.something.not.in.the.base.dwt.package". Not even restricting the check to leaf packages (packages containing only modules) would be ok in all cases, if we think of C libraries that are made available via a single D module. But I agree, having to capture all modules is no real problem.

You are right, modules in the root package are certainly a problem. Also the app.d file would have to be taken out of the equation.

But maybe just counting packages with actual modules + top level modules would work. I just try to get in that direction because I think that detecting just module conflicts is a bit too relaxed and it would be good to come as close as possible to the restricted system in that regard (without introducing child packages, which could of course still be done, even if just for different reasons).

I have to think a bit more about the consequences of not implementing my proposal, but with the right infrastructure and tools available, most issues should be solvable. E.g. having an IDE showing me the containing package name when I hover over an import line, having a commit hook that calls dub with some parameter that checks for conflicts with the registry, ...

Sorry, but that's a totally unrealistic case you make up there. Please, show me where such conflicts happen in reality and we can talk about it, but constructing cases like this is just... after all we have concrete issues with the restricted case but still not one concrete example of issues with the unrestricted case (and there is a sheer unlimited set of examples in the world).

I don't exactly know what you are referring to? To the commit hook thing? I am just saying that one can set up something like that, if he wants to be on the safe side. But never mind, it is quite possible that I am taking this conflict stuff a bit to serious. If you refer to the first sentence about consequences, I was not thinking about conflicts in this case, but rather whether my original goals for a package manager can still be met. "Consequences" might have been a bit of a too hard word, what I wanted to say was: "I have to think everything through again on top of the changed semantics".

I think I got your sentence mixed up a bit. Rereading it, I really don't know what I was talking about exactly and need to apologize for the slightly rude tone. I just think the commit hook is not any more or less needed than for the restricted case - just that the restricted case could just check the package name instead + verify locally that no forbidden name space is used.

Sorry, I can observe myself loosing track of the message while still reading it sometimes as my head is spinning with loads of other things (things like a HDD crash of my mail server didn't help there either). I severely need to get some things done to get my head free...

Re: Should packages be restricted to a single name space?

You are right, modules in the root package are certainly a problem. Also the app.d file would have to be taken out of the equation.

There should definitely be no warning about the app.d file, maybe just being explicit on what to put into the import path is enough? (See below)

But maybe just counting packages with actual modules + top level modules would work. I just try to get in that direction because I think that detecting just module conflicts is a bit too relaxed and it would be good to come as close as possible to the restricted system in that regard (without introducing child packages, which could of course still be done, even if just for different reasons).

Ok, I'll think about it. The problem is just, that the moment you go looser than the module level, it is very much dependent on how things are organized, for detecting what is ok and what not. That is why I introduced the child packages concept. My current thinking is, that you were probably right and we should rely on people being smart and that packages of "dumb" developers would not be used any way. Meaning it would be enough to provide a way of seeing which namespaces are already claimed by what packages and issuing a warning if you really happen to accidently introduce the exact same module as someone else did already.

I think I got your sentence mixed up a bit. Rereading it, I really don't know what I was talking about exactly and need to apologize for the slightly rude tone. I just think the commit hook is not any more or less needed than for the restricted case - just that the restricted case could just check the package name instead + verify locally that no forbidden name space is used.

Actually the proposal was a bit different. There was no need to verify locally, instead any D package found, named like the package name, would just be put into a separate import directory, which is then added to the -I paths, instead of the source directory itself (solving the issue with app.d and other not to be exported files). In fact something like that might still be a good idea, only that now it would have to be specified explicitly what packages should be put in the import directory. We might also need this for supporting multiple packages from a single repository. The beauty of the proposal was just, that no additional configuration was necessary, as the package name already included all the needed information (in the simple case, that the library is pure D), but adding something like "exportedPackages"=["vibe"] to the package.json would do the trick too. If no "exportedPackages" is given, dub could just continue to export the whole source tree, for both backwards compatibility and keeping configurations of trivial packages simple.

Sorry, I can observe myself loosing track of the message while still reading it sometimes as my head is spinning with loads of other things (things like a HDD crash of my mail server didn't help there either). I severely need to get some things done to get my head free...

I understand, to be honest I am pretty amazed on how many things you seem to handle at the same time. vibe, dub, newsgroup/forum activity, bug fixing, user support, ... and those are only the ones that are publicly visible. So no problem at all, if you don't answer for few days because you have more important things to do, I would not mind either.

Best regards,
Robert

Re: Should packages be restricted to a single name space?

On Tue, 12 Mar 2013 20:49:18 GMT, Robert wrote:

You are right, modules in the root package are certainly a problem. Also the app.d file would have to be taken out of the equation.

There should definitely be no warning about the app.d file, maybe just being explicit on what to put into the import path is enough? (See below)

But maybe just counting packages with actual modules + top level modules would work. I just try to get in that direction because I think that detecting just module conflicts is a bit too relaxed and it would be good to come as close as possible to the restricted system in that regard (without introducing child packages, which could of course still be done, even if just for different reasons).

Ok, I'll think about it. The problem is just, that the moment you go looser than the module level, it is very much dependent on how things are organized, for detecting what is ok and what not. That is why I introduced the child packages concept. My current thinking is, that you were probably right and we should rely on people being smart and that packages of "dumb" developers would not be used any way. Meaning it would be enough to provide a way of seeing which namespaces are already claimed by what packages and issuing a warning if you really happen to accidently introduce the exact same module as someone else did already.

You are right. The good thing is that with only warnings (or even just an informational query in the registry) instead of errors, that we can always make the rules stricter (or looser) without breaking anything. So we can lean back and observe how things will look in practice before deciding on concrete improvements.

I think I got your sentence mixed up a bit. Rereading it, I really don't know what I was talking about exactly and need to apologize for the slightly rude tone. I just think the commit hook is not any more or less needed than for the restricted case - just that the restricted case could just check the package name instead + verify locally that no forbidden name space is used.

Actually the proposal was a bit different. There was no need to verify locally, instead any D package found, named like the package name, would just be put into a separate import directory, which is then added to the -I paths, instead of the source directory itself (solving the issue with app.d and other not to be exported files). In fact something like that might still be a good idea, only that now it would have to be specified explicitly what packages should be put in the import directory. We might also need this for supporting multiple packages from a single repository. The beauty of the proposal was just, that no additional configuration was necessary, as the package name already included all the needed information (in the simple case, that the library is pure D), but adding something like "exportedPackages"=["vibe"] to the package.json would do the trick too. If no "exportedPackages" is given, dub could just continue to export the whole source tree, for both backwards compatibility and keeping configurations of trivial packages simple.

I see, I missed that. It could be a little problematic with IDEs, although doable. But let's just see how things turn out over the coming months and then we can decide which additional features or checks we really need. I'd say we document the recommendation to use a single root package with the same name as the package manager package (we really need a unique name for those ;)) in a prominent place and then see how well reality fits that recommendation. If issues crop up, we put additional measures in place (only warnings, never errors) and if all packages get along nicely, we could as well stop with the global package tree database (btw. it's really nice to have that because then we can finally take some objective statistics about the problem domain :)).

Sorry, I can observe myself loosing track of the message while still reading it sometimes as my head is spinning with loads of other things (things like a HDD crash of my mail server didn't help there either). I severely need to get some things done to get my head free...

I understand, to be honest I am pretty amazed on how many things you seem to handle at the same time. vibe, dub, newsgroup/forum activity, bug fixing, user support, ... and those are only the ones that are publicly visible. So no problem at all, if you don't answer for few days because you have more important things to do, I would not mind either.

It's just always tempting to continue the discussion, as it is actually quite a bit more interesting than some of the other (more) important things ;) But well, we'll be doing a small "project vacation" next week to dedicate a block of time purely for one or two topics to get them off the table. It that turns out well, it will make things much more comfortable again (improving automation is one of the topics and that will help to save a big chunk of regular amounts of work).

Re: Should packages be restricted to a single name space?

About uglifying the API, I think if I needed to do this, I would just derive from implementing class and override the method instantiating the vibe template. Wouldn't this work?

In particular, in my code I ended up wrapping Diet templates in rendering functions. This way I got an explicit interface to the template (the function signature), which I can document with DDoc comments. That is also why I like the new compileDietFileMixin, as I already have my interface explicit via the functions parameters, so having to pass over values explicitly twice seemed like a wasted effort. I basically considered the template as a part of the function, just at a different place. The reasons I did this:

  • I get an explicit interface, which can be documented.
  • I can put display related D code into the D function before instantiating the template.
  • If I wrote a reusable component, I can customize it by simply overriding the rendering functions. (No need to override Diet templates)
    -> An additional benefit: This way it is possible to use multiple variants of the component in the same code base.

So basically the fact that the rendering happens via a Diet template got an implementation detail, that is hidden from client code.

Best regards,

Robert

Re: Should packages be restricted to a single name space?

I see, I missed that. It could be a little problematic with IDEs, although doable.

How come? The code would only be also made available in an import directory, which is used for -I.

But let's just see how things turn out over the coming months and then we can decide which additional features or checks we really need. I'd say we document the recommendation to use a single root package with the same name as the package manager package (we really need a unique name for those ;)) in a prominent place and then see how well reality fits that recommendation.

I'd love that.

If issues crop up, we put additional measures in place (only warnings, never errors) and if all packages get along nicely, we could as well stop with the global package tree database (btw. it's really nice to have that because then we can finally take some objective statistics about the problem domain :)).

I think having such a tree available is always a good idea, except all packages adhered to the D package = package rule, but in this case we could as well have implemented my proposal ;-) Of course this tree could be factored out onto a different server and would not have to be part of the registry (also any automatic conflict check could be dropped, if they never seem to happen). But having a reliable way to determine what name spaces are in use seems to be valuable, also mapping files to packages and vice versa is a functionality that comes in handy at times.

It's just always tempting to continue the discussion, as it is actually quite a bit more interesting than some of the other (more) important things ;) But well, we'll be doing a small "project vacation" next week to dedicate a block of time purely for one or two topics to get them off the table. It that turns out well, it will make things much more comfortable again (improving automation is one of the topics and that will help to save a big chunk of regular amounts of work).

I know what you mean, I should be learning now and not discussing stuff I care about on the internet ;-)

Best regards,
Robert

Re: Should packages be restricted to a single name space?

Am 13.03.2013 14:56, schrieb Robert:

About uglifying the API, I think if I needed to do this, I would just derive from implementing class and override the method instantiating the vibe template. Wouldn't this work?

In particular, in my code I ended up wrapping Diet templates in rendering functions. This way I got an explicit interface to the template (the function signature), which I can document with DDoc comments. That is also why I like the new compileDietFileMixin, as I already have my interface explicit via the functions parameters, so having to pass over values explicitly twice seemed like a wasted effort. I basically considered the template as a part of the function, just at a different place. The reasons I did this:

  • I get an explicit interface, which can be documented.
  • I can put display related D code into the D function before instantiating the template.
  • If I wrote a reusable component, I can customize it by simply overriding the rendering functions. (No need to override Diet templates)

-> An additional benefit: This way it is possible to use multiple variants of the component in the same code base.

So basically the fact that the rendering happens via a Diet template got an implementation detail, that is hidden from client code.

Okay what I meant with overriding was more in cases where you have a
layout.dt that is extended by another template. In a derived project you
then want to use a different layout.dt. This is out of reach of any
object oriented features or whatever means.

Now if it weren't for staying compatible with Jade I would simply extend
the Diet template syntax with explicit parameter declarations so that
proper type checking can be done at the call site (and possibly
automatically generating a proper function or another alternative kind
of interface).

Re: Should packages be restricted to a single name space?

Okay what I meant with overriding was more in cases where you have a
layout.dt that is extended by another template. In a derived project you
then want to use a different layout.dt. This is out of reach of any
object oriented features or whatever means.

Ah, I see the extends syntax is the problem. :-) A not too bad solution would probably be to just call render functions (instead of defining blocks and extending it) in the layout.dt indirectly via delegates passed to the renderLayout method. I think I'll rewrite my current project this way and see how it works out. (The extends syntax did not scale very well for me anyway)

It would look something like this:
D code:
void renderLayout(HttpServerRequest req, HttpServerResponse res, RenderFunc contents, RenderFunc menu) {
mixin(renderDietFileMixin("project.layout.dt", res.bodyWriter));
}

project.layout.dt:

...
#menu

- menu(req, res);

#contents

- contents(req, res);


Now if it weren't for staying compatible with Jade I would simply extend
the Diet template syntax with explicit parameter declarations so that
proper type checking can be done at the call site (and possibly
automatically generating a proper function or another alternative kind
of interface).

I am actually quite fine with doing this explicitly, having vibe generate methods from a signature definition would probably not gain much in terms of code to write, also currently you have the documentation/interface together with the rest of the code.

Best regards,
Robert

Re: Should packages be restricted to a single name space?

Am 14.03.2013 13:40, schrieb Robert:

Okay what I meant with overriding was more in cases where you have a
layout.dt that is extended by another template. In a derived project you
then want to use a different layout.dt. This is out of reach of any
object oriented features or whatever means.

Ah, I see the extends syntax is the problem. :-) A not too bad solution would probably be to just call render functions (instead of defining blocks and extending it) in the layout.dt indirectly via delegates passed to the renderLayout method. I think I'll rewrite my current project this way and see how it works out. (The extends syntax did not scale very well for me anyway)

It would look something like this:
D code:
void renderLayout(HttpServerRequest req, HttpServerResponse res, RenderFunc contents, RenderFunc menu) {
mixin(renderDietFileMixin("project.layout.dt", res.bodyWriter));
}

project.layout.dt:

...
#menu

- menu(req, res);

#contents

- contents(req, res);


That will work, just the indentation of the HTML output will be messed
up (not that anyone will care...). But I actually like the way it is
possible to override for the extends way of doing things. No need for
delegates or classes.

Pages: 1 2 3 4