Re: DConf 2013 on kickstarter.com: we're live!

2012-11-14 Thread Mike van Dongen
On Monday, 22 October 2012 at 17:25:28 UTC, Andrei Alexandrescu 
wrote:
We're on! For one month starting today, we're raising funding 
for DConf 2013.


http://www.kickstarter.com/projects/2083649206/the-d-programming-language-conference-2013-0

Please pledge your support and encourage your friends to do the 
same. Hope to see you in 2013!



Thanks,

Andrei


I was about to donate, but after creating the accounts I found
out paying is only possible with a credit card.
Is there another way I can donate $25 (or $50+ if you can send a
shirt to the EU)?


Re: DConf 2013 on kickstarter.com: we're live!

2012-11-14 Thread Mike van Dongen
On Tuesday, 13 November 2012 at 01:08:01 UTC, Andrei Alexandrescu 
wrote:
Update - we've crossed $20K! At this point we're one major 
backer away from achieving the goal, and we're looking at a 
number of options. Please share with your friends and 
coworkers, and bring the discussion up with your employer's 
managers and recruiters. It should be an easier case to make 
now that among 107 backers we have sold out 20 early bird seats 
and 3 sponsorships before even having published a conference 
program.


We will make this happen!


Andrei


I was about to donate, but after creating the accounts I found
out paying is only possible with a credit card.
Is there another way I can donate $25 (or $50+ if you can send a
shirt to the EU)?


Re: DConf 2013 on kickstarter.com: we're live!

2012-11-14 Thread Mike van Dongen

On Tuesday, 13 November 2012 at 01:08:01 UTC, Andrei Alexandrescu
wrote:
Update - we've crossed $20K! At this point we're one major 
backer away from achieving the goal, and we're looking at a 
number of options. Please share with your friends and 
coworkers, and bring the discussion up with your employer's 
managers and recruiters. It should be an easier case to make 
now that among 107 backers we have sold out 20 early bird seats 
and 3 sponsorships before even having published a conference 
program.


We will make this happen!


Andrei


I was about to donate, but after creating the accounts I found
out paying is only possible with a credit card.
Is there another way I can donate $25 (or $50+ if you can send a
shirt to the EU)?


Re: DConf 2013 on kickstarter.com: we're live!

2012-11-14 Thread Mike van Dongen
On Tuesday, 13 November 2012 at 01:08:01 UTC, Andrei Alexandrescu 
wrote:
Update - we've crossed $20K! At this point we're one major 
backer away from achieving the goal, and we're looking at a 
number of options. Please share with your friends and 
coworkers, and bring the discussion up with your employer's 
managers and recruiters. It should be an easier case to make 
now that among 107 backers we have sold out 20 early bird seats 
and 3 sponsorships before even having published a conference 
program.


We will make this happen!


Andrei


I was about to donate, but after creating the accounts I found 
out paying is only possible with a credit card.
Is there another way I can donate $25 (or $50+ if you can send a 
shirt to the EU)?


Re: DConf 2013 on kickstarter.com: we're live!

2012-11-14 Thread Mike van Dongen
On Tuesday, 13 November 2012 at 01:08:01 UTC, Andrei Alexandrescu 
wrote:
Update - we've crossed $20K! At this point we're one major 
backer away from achieving the goal, and we're looking at a 
number of options. Please share with your friends and 
coworkers, and bring the discussion up with your employer's 
managers and recruiters. It should be an easier case to make 
now that among 107 backers we have sold out 20 early bird seats 
and 3 sponsorships before even having published a conference 
program.


We will make this happen!


Andrei


I was about to donate, but after creating the accounts I found 
out paying is only possible with a credit card.
Is there another way I can donate $25 (or $50+ if you can send a 
shirt to the EU)?


Re: Uri class and parser

2012-11-08 Thread Mike van Dongen
On Thursday, 8 November 2012 at 23:51:47 UTC, Jonathan M Davis 
wrote:

On Friday, November 09, 2012 00:42:42 jerro wrote:

> After trying your solution I found out I was calling
> indexOf(string, char) which apparently is different than
> indexOf(string, string) as I now no longer have that error.
> Instead, when I call parse on compile time I get the 
> following

> at the method parse:
> Error: URI class literals cannot be returned from CTFE

It looks like you can't have class enums. This fails too:

class A{}
enum a = new A;

I don't think you can get around this


Nope. To some extent, classes can be used at compile time, but 
they can't
persist from compile time to runtime. So, if you really want a 
type which is

useable with CTFE, make it a struct, not a class.

- Jonathan M Davis


Then I shall make it a struct. But is the following acceptable in 
phobos?


On Thursday, 8 November 2012 at 15:10:18 UTC, Mike van Dongen 
wrote:
I agree with Jens Mueller on the fact that URI should be a 
struct instead of a class. But then I won't be able to return 
null anymore so I should throw an exception when an invalid URI 
has been passed to the constructor.




Re: Uri class and parser

2012-11-08 Thread Mike van Dongen

On Thursday, 8 November 2012 at 17:02:25 UTC, jerro wrote:

Thnx. Got myself some new errors ;)
It seems that std.string.indexOf() does not work at compile 
time. Is there a solution or alternative method for this?


I guess the proper solution would be to make std.string.indexOf 
work at compile time. It looks like changing the first


if (std.ascii.isASCII(c))

line in std.string.indexOf to

if (!__ctfe && std.ascii.isASCII(c))


Makes it work at compile time.


After trying your solution I found out I was calling 
indexOf(string, char) which apparently is different than 
indexOf(string, string) as I now no longer have that error.
Instead, when I call parse on compile time I get the following at 
the method parse:

Error: URI class literals cannot be returned from CTFE

The method returns an instance of class URI and works perfectly 
when called at runtime.
As far as I can see it has nothing to do with my previous 
problem. I do thank you for your answer.


Re: Uri class and parser

2012-11-08 Thread Mike van Dongen

On Thursday, 8 November 2012 at 15:32:59 UTC, jerro wrote:
Something entirely else is the CTFE compatibility of URI. At 
first I though that because a new instance of URI can be 
created as a const, it would be evaluated on compile time.

This is part of how I test CTFE at the moment:

const URI uri36 = URI.parse("http://dlang.org/";);
assert(uri36.scheme == "http");

I tried changing 'const' to 'static' but that resulted in an 
error.
(_adSort cannot be interpreted at compile time, because it has 
no available source code)


Now I'm not sure anymore how to test if my code meets the CTFE 
requirements.


To force something to be evaluated at compile time, you can 
assign it to an enum, like this:


enum uri = URI.parse("http://dlang.org/";);


Thnx. Got myself some new errors ;)
It seems that std.string.indexOf() does not work at compile time. 
Is there a solution or alternative method for this?


Re: Uri class and parser

2012-11-08 Thread Mike van Dongen
Been thinking about this for a while now, but I can't decide 
which one I should choose.


Currently there is a class URI which has an static method 
(parser) which returns an instance of URI on success. On failure 
it will return null.


I agree with Jens Mueller on the fact that URI should be a struct 
instead of a class. But then I won't be able to return null 
anymore so I should throw an exception when an invalid URI has 
been passed to the constructor.


I'm not sure if this is how problems are being handled in phobos.


Something entirely else is the CTFE compatibility of URI. At 
first I though that because a new instance of URI can be created 
as a const, it would be evaluated on compile time.

This is part of how I test CTFE at the moment:

const URI uri36 = URI.parse("http://dlang.org/";);
assert(uri36.scheme == "http");

I tried changing 'const' to 'static' but that resulted in an 
error.
(_adSort cannot be interpreted at compile time, because it has no 
available source code)


Now I'm not sure anymore how to test if my code meets the CTFE 
requirements.



I hope someone can shed some light on my problems and help me 
make a decision.




Re: Uri class and parser

2012-10-26 Thread Mike van Dongen

On Friday, 26 October 2012 at 14:22:07 UTC, Adam D. Ruppe wrote:
On Friday, 26 October 2012 at 14:13:21 UTC, Mike van Dongen 
wrote:
I am however considering it because even though not (clearly) 
defined, they are URIs and they are often used.


The basedOn function in my uri struct in cgi.d does it:
https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff/blob/master/cgi.d#L1702

The unit test below the function is focused on checking the 
relative function.


On Friday, 26 October 2012 at 11:52:09 UTC, John Chapman wrote:
It would also be nice to support combining URIs from an 
absolute and relative portion.


If relative URIs will be supported I agree there should be a 
method that merges two (incomplete) URIs into one (valid) URI.


Re: Uri class and parser

2012-10-26 Thread Mike van Dongen

On Friday, 26 October 2012 at 11:52:09 UTC, John Chapman wrote:

Looks good.

Does it handle relative URIs? It would also be nice to support 
combining URIs from an absolute and relative portion.


Another omission is handling file URIs.


It doesn't support relative URIs as their syntax is not 
officially defined in RFC 3986, nor are there any relative URIs 
in the examples:

http://tools.ietf.org/html/rfc3986#section-1.1.2

I am however considering it because even though not (clearly) 
defined, they are URIs and they are often used.



Definition of URI on Wikipedia:
"In computing, a uniform resource identifier (URI) is a string 
of characters used to identify a name or a resource."





Re: Uri class and parser

2012-10-25 Thread Mike van Dongen

On Thursday, 25 October 2012 at 13:59:59 UTC, Jens Mueller wrote:

Just some small nit-picks.


That's what I was hoping for :D


  in general checkout the Phobos style guide regarding function 
names

  etc.
  http://dlang.org/dstyle.html



  add some unittests.


Thanks! I haven't read that page before, but I think my code is 
already in that style.
That page referred to one about code coverage, which I didn't 
know is an option in dmd.

I added some unittests and increased the code coverage to 100%.
http://dlang.org/code_coverage.html



* Rename URIerror to URIException
  and make it derive from Exception
  I assume it is allowed to recover from such errors.
* URI_Encode => uriEncode


I know it was hard to tell, but that's not my code.


* The code looks sometimes a bit C-ish (gotos) and deeply 
nested. Maybe

  some functions could be refactored to ease maintenance.


I'm not sure what functions you mean.



I hope the module makes it into Phobos. I suggest std.net.uri.


I agree I should move it, so moved my code into a new file, 
'std/net/uri.d'.

https://github.com/MikevanDongen/phobos/blob/uri-parser/std/net/uri.d


* Why is Uri a class and not a struct? Do you expect people to 
derive
  from Uri? But then you need to check whether URI.init makes 
sense.

  According to the Phobos style Uri should be renamed to URI.


The renaming is done. At the start, the class was quite general 
in a way I wanted to make others derive from it. That plus the 
little experience I have with structs in D made me use a class.
Now I don't see a reason why anyone would derive from it, so I 
think it should either be a final class (as Jacob Carlborg 
suggested) or a struct.




* Maybe you should add a constructor in addition to URI.parse()
  to construct some simple URIs.


Do you mean with parameters (strings?) that simply set the 
properties?



* Check whether it is const correct. Is const used where it 
makes sense?


Been thinking about that myself aswell. Both for return values 
and parameters.




* You could implement opEquals to allow checking for equal URIs.


I like this suggestion! :)



* Should URIs be only movable? Then you should add
  @disable this(this);


http://forum.dlang.org/thread/mohceehplxdhsdllx...@forum.dlang.org
I'm not sure what movable means or what @disable does. That 
thread doesn't explain it means very clear.



* Regarding documentation. Please state whether it works in 
CTFE. Probably


I'll look that up ;)



I hope the module makes it into Phobos. I suggest std.net.uri.
Thank you very much for contributing.

Jens


Again, thanks for being supportive; that's what makes me continue 
;)




Re: Uri class and parser

2012-10-25 Thread Mike van Dongen
On Wednesday, 24 October 2012 at 12:47:15 UTC, Adam D. Ruppe 
wrote:

BTW don't forget that this is legal:

?value&value=1&value=2

The appropriate type for the AA is

string[][string]


Thanks for the type! It's now implemented.

uri = Uri.parse("http://dlang.org/?value&value=1&value=2";);
assert(uri.queryMulti == ["value": ["", "1", "2"]]);
assert(uri.query["value"] == "2");


On Thursday, 25 October 2012 at 11:44:11 UTC, Jacob Carlborg 
wrote:

Awesome, now it's only missing documentation :)


It's a dirty job, but someone's gotta do it ;)
I have commented all code that's not straightforward, but nothing 
for the Ddoc.


Can you give me an example of how specific I need to be in the 
documentation?



On Wednesday, 24 October 2012 at 19:54:54 UTC, Jacob Carlborg 
wrote:

On 2012-10-24 20:22, Mike van Dongen wrote:
As all my code is part of a single class and the file 
std/uri.d already
existed, I decided to 'just' append my code to the file. 
Should I
perhaps put it in another file as the private methods you 
mentioned are

not relevant to my code?


If the some methods aren't used by the URI parser you should 
remove the. If they're used I would suggested you move the 
further down in the code, possibly at the bottom.


It's not clear to me what you mean by this.
To clarify: the first 520 lines weren't written by me, and the 
code I have written doesn't use any of those functions.
Atleast, for now; Moving the functions 'encode' and 'decode' into 
the class Uri may be useful at a later point.


As I'm the new kid on the block, I'm trying not to break others' 
code. ;)


Re: Uri class and parser

2012-10-25 Thread Mike van Dongen
On Wednesday, 24 October 2012 at 20:36:51 UTC, Adam D. Ruppe 
wrote:
On Wednesday, 24 October 2012 at 19:54:54 UTC, Jacob Carlborg 
wrote:
A nitpick, I'm not really an expert on URI's but is "fragment" 
really the correct name for that I would call the "hash"? That 
would be "nose" in the example below.


Yes, that's the term in the standard.

http://en.wikipedia.org/wiki/Fragment_identifier


The only reason I used "fragment" was because both the RFC and 
the Wikipedia page called it that way. I hate to break protocol ;)


Cool. It would be nice to have a way to set the query and path 
as an (associative) array as well.


Now it allows you to create/edit an URI. You can do so by using 
an array or string, whichever you prefer.
I also added a toString() method and fixed the indentation to 4 
spaces, instead of 1 tab.


uri = new Uri();
uri.scheme = "foo";
uri.username = "username";
uri.password = "password";
uri.host = "example.com";
uri.port = 8042;
uri.path = ["over", "there", "index.dtb"];
uri.query = ["type": "animal", "name": "narwhal", "novalue": ""];
uri.fragment = "nose";
assert(uri.toString() == 
"foo://username:passw...@example.com:8042/over/there/index.dtb?novalue=&name=narwhal&type=animal#nose");




Re: Uri class and parser

2012-10-24 Thread Mike van Dongen
On Wednesday, 24 October 2012 at 07:38:58 UTC, Jacob Carlborg 
wrote:

I would have expected a few additional components, like:

* Domain
* Password
* Username
* Host
* Hash

A way to build an URI base on the components.
It would be nice if there were methods for getting/setting the 
path component as an array. Also methods for getting/setting 
the query component as an associative array.


Thanks for the suggestions!
I've added many, if not all, of them to the repo:

- Identifying/separating the username, password (together the 
userinfo), the domain and the port number from the authority.
- The hash now also can be get/set and the same thing goes for 
the data in the query



On Wednesday, 24 October 2012 at 12:47:15 UTC, Adam D. Ruppe 
wrote:
On Wednesday, 24 October 2012 at 07:38:58 UTC, Jacob Carlborg 
wrote:
It would be nice if there were methods for getting/setting the 
path component as an array. Also methods for getting/setting 
the query component as an associative array.


BTW don't forget that this is legal:

?value&value=1&value=2

The appropriate type for the AA is

string[][string]


It does not yet take into account the fact that multiple query 
elements can have the same name. I'll be working on that next.



On Wednesday, 24 October 2012 at 07:38:58 UTC, Jacob Carlborg 
wrote:
A few stylistic issues. There are a lot of places where you 
haven't indented the code, at least how it looks like on github.


I wouldn't put the private methods at the top.


As for the indentations, I use tabs with the size of 4 spaces.
Viewing the code on Github (in Chromium) you'll see tabs of 8 
spaces.

I'm not sure what the phobos standard is?

As all my code is part of a single class and the file std/uri.d 
already existed, I decided to 'just' append my code to the file. 
Should I perhaps put it in another file as the private methods 
you mentioned are not relevant to my code?



You may be able to see the new getters by checking out this 
unittest:


uri = 
Uri.parse("foo://username:passw...@example.com:8042/over/there/index.dtb?type=animal&name=narwhal&novalue#nose");

assert(uri.scheme == "foo");
assert(uri.authority == "username:passw...@example.com:8042");
assert(uri.path == "over/there/index.dtb");
assert(uri.pathAsArray == ["over", "there", "index.dtb"]);
assert(uri.query == "type=animal&name=narwhal&novalue");
assert(uri.queryAsArray == ["type": "animal", "name": "narwhal", 
"novalue": ""]);

assert(uri.fragment == "nose");
assert(uri.host == "example.com");
assert(uri.port == 8042);
assert(uri.username == "username");
assert(uri.password == "password");
assert(uri.userinfo == "username:password");
assert(uri.queryAsArray["type"] == "animal");
assert(uri.queryAsArray["novalue"] == "");
assert("novalue" in uri.queryAsArray);
assert(!("nothere" in uri.queryAsArray));


Uri class and parser

2012-10-23 Thread Mike van Dongen

Hi all!

I've been working on an URI parser which takes a string and then 
separates the parts and puts them in the correct properties.
If a valid URI was provided, the (static) parser will return an 
instance of Uri.


I've commented all relevant lines of code and tested it using 
unittests.


Now what I'm wondering is if it meets the phobos requirements and 
standards.

And of course if you think I should do a pull request on GitHub!

My code can be found here, at the bottom of the already existing 
file uri.d:

https://github.com/MikevanDongen/phobos/blob/uri-parser/std/uri.d


Thanks,

Mike van Dongen.