Re: Using attributes inside template instantiation

2014-06-26 Thread Uranuz via Digitalmars-d-learn

But if I write

@("hello") struct Hello {}

so all of the variables that have type Hello will have attribute 
@("hello") like come type qualifier because attribute is a part 
of declaration of Hello. Do I understand correctly?


import except one?

2014-06-26 Thread Puming via Digitalmars-d-learn

Hi,

I'm using scriptlike, which imports everything from std.process 
for convienience, but I also need to import another module, which 
contains a class `Config`, it conflicts with std.process.Config. 
I don't actually need std.process.Config, but I need many other 
symbols in scriptlike and std.process.


What I want to achieve is to import ALL symbols from scriptlike 
EXCEPT std.process.Config, something like:


```d
import scriptlike: !Config;
```

or rename it AND import all other symbols, to resolve the 
confliction.


```d
import scriptlike: *, Cfg = Config;
```

I don't know how to achieve these effects, selective import and 
rename seems to only import the one I specified.


Re: import except one?

2014-06-26 Thread bearophile via Digitalmars-d-learn

Puming:

I'm using scriptlike, which imports everything from std.process 
for convienience, but I also need to import another module, 
which contains a class `Config`, it conflicts with 
std.process.Config. I don't actually need std.process.Config, 
but I need many other symbols in scriptlike and std.process.


What I want to achieve is to import ALL symbols from scriptlike 
EXCEPT std.process.Config, something like:


```d
import scriptlike: !Config;


A similar idea is present in Haskell, but it was refused by 
Walter.


The use of scriptlike is going to cause you similar problems, 
it's not for a fine tuning of imports.


Bye,
bearophile


Re: [OT]I throw in the towel

2014-06-26 Thread Chris via Digitalmars-d-learn

On Thursday, 26 June 2014 at 08:36:15 UTC, Chris wrote:

On Wednesday, 25 June 2014 at 09:29:35 UTC, Orfeo wrote:
I wanted to create a simple application to display and edit 
data from  postgresql database using GtkD and ddb 
(https://github.com/pszturmaj/ddb)


The application should run on WinXp or Win7. After a week of 
work I throw in the towel ...


1. The first problem
$ dub build
   Unexpected Termination OPTLINK at t = EIP 0040F5Ba
After many attempts to find a solution 
(http://forum.dlang.org/thread/gskuwiynupngpungy...@forum.dlang.org)


$ dub build --rdmd

After writing a bit of code another problem:

$ dub build --rdmd
 Error 45: Too Much Data for Old DEBUG CodeView format

$ dub --build=release --rdmd
C:\Documents and Settings\dao\Application 
Data\dub\packages\gtk-d-2.3.3\src\gtk\Builder.d(489): Error: 
ICE: cannot append 'char' to 'string'


(see https://github.com/gtkd-developers/GtkD/issues/91 and 
https://issues.dlang.org/show_bug.cgi?id=12243)


I love D but, with tail between legs, I come back to csharp...

(BTW on Linux it's works well)


That's why I think D needs its own GUI like Java Swing. You 
could however try PyD and use a Python UI (i.e. have D do the 
work and use a Python UI) or you try a solution with, say, Lua. 
Or anything that is based on C like Tk and IUP, if you don't 
mind writing the interfaces yourself. Cf.


https://en.wikipedia.org/wiki/IUP_%28software%29

See also

https://en.wikipedia.org/wiki/List_of_widget_toolkits#Based_on_C_.28including_bindings_to_other_languages.29


Maybe this could be of interest to you:

http://www.tecgraf.puc-rio.br/iup/


Re: [OT]I throw in the towel

2014-06-26 Thread Chris via Digitalmars-d-learn

On Wednesday, 25 June 2014 at 09:29:35 UTC, Orfeo wrote:
I wanted to create a simple application to display and edit 
data from  postgresql database using GtkD and ddb 
(https://github.com/pszturmaj/ddb)


The application should run on WinXp or Win7. After a week of 
work I throw in the towel ...


1. The first problem
$ dub build
Unexpected Termination OPTLINK at t = EIP 0040F5Ba
After many attempts to find a solution 
(http://forum.dlang.org/thread/gskuwiynupngpungy...@forum.dlang.org)


$ dub build --rdmd

After writing a bit of code another problem:

$ dub build --rdmd
  Error 45: Too Much Data for Old DEBUG CodeView format

$ dub --build=release --rdmd
C:\Documents and Settings\dao\Application 
Data\dub\packages\gtk-d-2.3.3\src\gtk\Builder.d(489): Error: 
ICE: cannot append 'char' to 'string'


(see https://github.com/gtkd-developers/GtkD/issues/91 and 
https://issues.dlang.org/show_bug.cgi?id=12243)


I love D but, with tail between legs, I come back to csharp...

(BTW on Linux it's works well)


That's why I think D needs its own GUI like Java Swing. You could 
however try PyD and use a Python UI (i.e. have D do the work and 
use a Python UI) or you try a solution with, say, Lua. Or 
anything that is based on C like Tk and IUP, if you don't mind 
writing the interfaces yourself. Cf.


https://en.wikipedia.org/wiki/IUP_%28software%29

See also

https://en.wikipedia.org/wiki/List_of_widget_toolkits#Based_on_C_.28including_bindings_to_other_languages.29


Re: [OT]I throw in the towel

2014-06-26 Thread Chris via Digitalmars-d-learn

On Thursday, 26 June 2014 at 08:39:46 UTC, Chris wrote:

On Thursday, 26 June 2014 at 08:36:15 UTC, Chris wrote:

On Wednesday, 25 June 2014 at 09:29:35 UTC, Orfeo wrote:
I wanted to create a simple application to display and edit 
data from  postgresql database using GtkD and ddb 
(https://github.com/pszturmaj/ddb)


The application should run on WinXp or Win7. After a week of 
work I throw in the towel ...


1. The first problem
$ dub build
  Unexpected Termination OPTLINK at t = EIP 0040F5Ba
After many attempts to find a solution 
(http://forum.dlang.org/thread/gskuwiynupngpungy...@forum.dlang.org)


$ dub build --rdmd

After writing a bit of code another problem:

$ dub build --rdmd
Error 45: Too Much Data for Old DEBUG CodeView format

$ dub --build=release --rdmd
C:\Documents and Settings\dao\Application 
Data\dub\packages\gtk-d-2.3.3\src\gtk\Builder.d(489): Error: 
ICE: cannot append 'char' to 'string'


(see https://github.com/gtkd-developers/GtkD/issues/91 and 
https://issues.dlang.org/show_bug.cgi?id=12243)


I love D but, with tail between legs, I come back to csharp...

(BTW on Linux it's works well)


That's why I think D needs its own GUI like Java Swing. You 
could however try PyD and use a Python UI (i.e. have D do the 
work and use a Python UI) or you try a solution with, say, 
Lua. Or anything that is based on C like Tk and IUP, if you 
don't mind writing the interfaces yourself. Cf.


https://en.wikipedia.org/wiki/IUP_%28software%29

See also

https://en.wikipedia.org/wiki/List_of_widget_toolkits#Based_on_C_.28including_bindings_to_other_languages.29


Maybe this could be of interest to you:

http://www.tecgraf.puc-rio.br/iup/


See also: http://wiki.dlang.org/Libraries_and_Frameworks


Re: DDoc and private members / mixins / UDAs

2014-06-26 Thread Stefan Frijters via Digitalmars-d-learn

On Thursday, 26 June 2014 at 02:33:43 UTC, Mathias LANG wrote:
On Wednesday, 25 June 2014 at 18:49:27 UTC, Stefan Frijters 
wrote:
Let me preface this by admitting that I'm not sure I'm using 
the DDoc functionality properly at all, so let me know if my 
questions are bogus.


Is it possible to:
- Add private members to documentation?
- Have DDoc do its thing after mixins have been handled?
- Access UDAs?

To expand on the last point: in my code I currently use UDAs 
to annotate variables that can be set in an input file; at 
compile time I use __traits to find all of them and create a 
parser etc. for them. I would really like to be able to create 
a minimal documentation, which only includes all such 
UDA-annotated variables from all modules, so it can be used as 
a short manual for the end user, rather than being developer 
documentation. I was thinking of using a LaTeX template and 
using the absence or presence of the UDA to somehow insert a 
macro that is either just blank or actually adds the 
documentation.


Any tips to achieve this in a different fashion are also 
appreciated.


Kind regards,

Stefan Frijters


1) You might be interested by ddox [1] which provides more 
functionality and a nicer output than DDoc (actually, the 
phobos docs are being replacd by it).
As you can see in the example, you can filter what goes in and 
what doesn't, as well as the minimum protection level (so you 
can chose to put private in it).
Note that if you have a dub-based project, you can just run 
"dub --build=ddox" to get it working.


2) Yes for regular mixin, no for template mixins. Example:
mixin strToSym!(moduleName!moduleName); // Template mixin
mixin("int a = 42;");   // regular mixin

Will output (using dmd -Xfdocs.json module.d):
   {
"name" : "strToSym!(\"std.traits\")",
"kind" : "mixin",
"line" : 62
   },
   {
"name" : "a",
"kind" : "variable",
"protection" : "private",
"file" : "CppWrapper.d-mixin-63",
"line" : 63,
"deco" : "i",
"init" : "42"
   },


3) Nope. Again, example:
@("ThisIsAFunction")
void foo() {}

Ouputs in the docs.json:
   {
"name" : "foo",
"kind" : "function",
"protection" : "private",
"file" : "CppWrapper.d",
"line" : 66,
"deco" : "FZv",
"endline" : 66
   },


Hope this helps !

[1]: https://github.com/rejectedsoftware/ddox


Thank you! Some comments:

1) I will check it out. It looks like it may be a bit too 
HTML-centric for my taste though.


2) Here, I meant if there is a way to have the comment included 
as well. It doesn't seem like this is the case (if there are no 
hidden switches I don't know about):


/// Comment
int a;
/// Ditto
mixin("int b;");
mixin("///Ditto\nint c;");

{
  "kind" : "module",
  "file" : "testdoc2.d",
  "members" : [
   {
"name" : "a",
"kind" : "variable",
"comment" : "Comment\n",
"line" : 2,
"char" : 5,
"deco" : "i"
   },
   {
"name" : "b",
"kind" : "variable",
"file" : "testdoc2.d-mixin-4",
"line" : 4,
"char" : 5,
"deco" : "i"
   },
   {
"name" : "c",
"kind" : "variable",
"file" : "testdoc2.d-mixin-5",
"line" : 6,
"char" : 5,
"deco" : "i"
   }
  ]
 },

3) That's a shame. I guess I can work around it by doing a dirty 
grep beforehand and using that information to filter the json...


Related question: I found a pull request to add 
__traits(documentation, ...)[1] which would also allow me to 
solve my problem as a workaround, does anyone know if this is 
still moving forward?


[1]: https://github.com/D-Programming-Language/dmd/pull/3531


Re: DDoc and private members / mixins / UDAs

2014-06-26 Thread bearophile via Digitalmars-d-learn

Stefan Frijters:

I found a pull request to add __traits(documentation, ...)[1] 
which would also allow me to solve my problem as a workaround, 
does anyone know if this is still moving forward?


You can state in that GitHub thread that you could use that 
feature. There are many stalled nice enhancements in GitHub.


Bye,
bearophile


close program by code

2014-06-26 Thread pgtkda via Digitalmars-d-learn

How can i close my application by code?


Re: [OT]I throw in the towel

2014-06-26 Thread seany via Digitalmars-d-learn

+ 1 for own GUI + graphics module for D


Re: Assosiative array pop

2014-06-26 Thread seany via Digitalmars-d-learn

On Wednesday, 25 June 2014 at 14:17:50 UTC, Meta wrote:

If you want something like a hash table that preserves 
insertion order, you could try using an array of tuples 
instead. Then to "pop" the first element, just do 'arr = 
arr[1..$]'.


Thank you, this is _exactly_ what I was looking for! Thank you so
much!


Re: Assosiative array pop

2014-06-26 Thread Rene Zwanenburg via Digitalmars-d-learn

On Wednesday, 25 June 2014 at 14:17:50 UTC, Meta wrote:

Then to "pop" the first element, just do 'arr = arr[1..$]'.


Or import std.array to get the range primitives for slices:

import std.array;

void main()
{
  auto arr = [1, 2, 3, 4];
  arr.popFront();
  assert(arr.front == 2);
}


Re: close program by code

2014-06-26 Thread FreeSlave via Digitalmars-d-learn

On Thursday, 26 June 2014 at 09:05:23 UTC, pgtkda wrote:

How can i close my application by code?


Do you mean exit status? Just call exit function from C library.

import std.c.stdlib;

void main()
{
exit(0);
}


Re: close program by code

2014-06-26 Thread pgtkda via Digitalmars-d-learn

On Thursday, 26 June 2014 at 09:58:50 UTC, FreeSlave wrote:

On Thursday, 26 June 2014 at 09:05:23 UTC, pgtkda wrote:

How can i close my application by code?


Do you mean exit status? Just call exit function from C library.

import std.c.stdlib;

void main()
{
exit(0);
}


wow, thank you very much :)



Re: new and GC.malloc fail, core.stdc.malloc works

2014-06-26 Thread John Colvin via Digitalmars-d-learn

On Wednesday, 25 June 2014 at 14:44:22 UTC, John Colvin wrote:

On Tuesday, 24 June 2014 at 10:16:38 UTC, bearophile wrote:

John Colvin:

I'm getting OutOfMemoryErrors on some machines when calling 
GC.malloc (or new) for anything large (more than about 1GB), 
where core.stdc.malloc works fine.


I think that when you go in territories where most people have 
not done much coding in D, like allocating than 1 GB in one 
shot, you hit some bugs. In general if some part of D is not 
used a lot, you have to assume it's buggy. Please report in 
Bugzilla the problems you have located.


Bye,
bearophile


After a little more investigation It seems that I'm getting an 
OutOfMemoryError at around 1GB memory usage, regardless of the 
granularity of allocation.


User error, carry on, nothing to see here...


Re: close program by code

2014-06-26 Thread John Colvin via Digitalmars-d-learn

On Thursday, 26 June 2014 at 09:58:50 UTC, FreeSlave wrote:

On Thursday, 26 June 2014 at 09:05:23 UTC, pgtkda wrote:

How can i close my application by code?


Do you mean exit status? Just call exit function from C library.

import std.c.stdlib;

void main()
{
exit(0);
}


Will destructors and/or scope statements be executed if you exit 
this way?


Unqualified __FUNCTION__

2014-06-26 Thread Nordlöw

Is there an unqualified version of __FUNCTION__ that returns just

treeContentId

instead of

fs.Dir.treeContentId

?


Re: close program by code

2014-06-26 Thread Rene Zwanenburg via Digitalmars-d-learn

On Thursday, 26 June 2014 at 10:40:00 UTC, John Colvin wrote:

On Thursday, 26 June 2014 at 09:58:50 UTC, FreeSlave wrote:

On Thursday, 26 June 2014 at 09:05:23 UTC, pgtkda wrote:

How can i close my application by code?


Do you mean exit status? Just call exit function from C 
library.


import std.c.stdlib;

void main()
{
   exit(0);
}


Will destructors and/or scope statements be executed if you 
exit this way?


They won't. Same for module destructors.

If you need those to work, another option is to throw some custom 
Exception type which is only caught in main.


Re: Unqualified __FUNCTION__

2014-06-26 Thread bearophile via Digitalmars-d-learn

Nordlöw:

Is there an unqualified version of __FUNCTION__ that returns 
just


treeContentId

instead of

fs.Dir.treeContentId

?


I suggest to use the string functions to strip the part you need.

Bye,
bearophile


Re: Returning fixed size arrays

2014-06-26 Thread bearophile via Digitalmars-d-learn

John Colvin:

isn't this exactly what the System V ABI specifies anyway? 
Large aggregate returns are allocated on the calling stack, 
passed by hidden pointer.


So do you know why D is not using that design?

Bye,
bearophile


Re: close program by code

2014-06-26 Thread Chris Nicholson-Sauls via Digitalmars-d-learn

On Thursday, 26 June 2014 at 11:07:37 UTC, Rene Zwanenburg wrote:


They won't. Same for module destructors.

If you need those to work, another option is to throw some 
custom Exception type which is only caught in main.


I really wish this wasn't the answer, but for some programs I've 
had to resort to it myself.  For at least one I've defined an 
Exception type that carries a status code payload to be returned 
by main.  D needs its own exit().


There's been this request in the bugzilla since 2009:
https://issues.dlang.org/show_bug.cgi?id=3462


Re: Returning fixed size arrays

2014-06-26 Thread John Colvin via Digitalmars-d-learn

On Thursday, 26 June 2014 at 12:06:34 UTC, bearophile wrote:

John Colvin:

isn't this exactly what the System V ABI specifies anyway? 
Large aggregate returns are allocated on the calling stack, 
passed by hidden pointer.


So do you know why D is not using that design?

Bye,
bearophile


It is, but a copy is made after the function returns anyway, for 
reasons unknown to me. For some reason the optimizer can't elide 
it (ldc2 -O5 -release, with a pragma(LDC_never_inline); inside 
foo).


Re: Returning fixed size arrays

2014-06-26 Thread bearophile via Digitalmars-d-learn

John Colvin:


It is,


As far as I know, D is using that as an optimization, not as an 
ABI default that must happen at all optimization levels.



but a copy is made after the function returns anyway, for 
reasons unknown to me. For some reason the optimizer can't 
elide it (ldc2 -O5 -release, with a pragma(LDC_never_inline); 
inside foo).


Right. perhaps I'll have to ask this again in the main D 
newsgroup (but perhaps better to do it Monday).


Bye,
bearophile


Re: close program by code

2014-06-26 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jun 26, 2014 at 01:23:17PM +, Chris Nicholson-Sauls via 
Digitalmars-d-learn wrote:
> On Thursday, 26 June 2014 at 11:07:37 UTC, Rene Zwanenburg wrote:
> >
> >They won't. Same for module destructors.
> >
> >If you need those to work, another option is to throw some custom
> >Exception type which is only caught in main.
> 
> I really wish this wasn't the answer, but for some programs I've had
> to resort to it myself.  For at least one I've defined an Exception
> type that carries a status code payload to be returned by main.  D
> needs its own exit().

I've done the same for my own programs:

class ExitException : Exception
{
int status;
this(int _status, string file=__FILE__,
size_t line=__LINE__)
{
super(file,line);
status = _status;
}
}
void exit(int status=0) {
throw new ExitException(status);
}
int main(string[] args) {
try {
...
return 0;
} catch(ExitException e) {
return e.status;
} catch(Exception e) {
... // real exception here
return 1;
}
}

It works reasonably well for single-threaded program, but as the
following bug states, there's no nice way to terminate a multithreaded
program:


> There's been this request in the bugzilla since 2009:
> https://issues.dlang.org/show_bug.cgi?id=3462

If you have any good ideas, please chime in on the bug report!


T

-- 
"I'm not childish; I'm just in touch with the child within!" - RL


SList: How do I use linearRemove?

2014-06-26 Thread Lemonfiend via Digitalmars-d-learn

---
module main;

void main()
{
struct Tree { int apples; }

import std.container;
SList!Tree list;

Tree tree = Tree(5);
list.insert(tree);
//list.linearRemove(tree); // <-- Error. What is the correct way?
}
---


Re: close program by code

2014-06-26 Thread FreeSlave via Digitalmars-d-learn

On Thursday, 26 June 2014 at 11:07:37 UTC, Rene Zwanenburg wrote:

On Thursday, 26 June 2014 at 10:40:00 UTC, John Colvin wrote:

On Thursday, 26 June 2014 at 09:58:50 UTC, FreeSlave wrote:

On Thursday, 26 June 2014 at 09:05:23 UTC, pgtkda wrote:

How can i close my application by code?


Do you mean exit status? Just call exit function from C 
library.


import std.c.stdlib;

void main()
{
  exit(0);
}


Will destructors and/or scope statements be executed if you 
exit this way?


They won't. Same for module destructors.


Module destructors are called. At least in DMD v2.065. I believe 
d runtime automatically register this with atexit function.




Re: SList: How do I use linearRemove?

2014-06-26 Thread bearophile via Digitalmars-d-learn

Lemonfiend:

	//list.linearRemove(tree); // <-- Error. What is the correct 
way?

}
---


linearRemove is linear, so I think it accepts a range. Perhaps 
the "once" range is enough.


Bye,
bearophile


Re: SList: How do I use linearRemove?

2014-06-26 Thread Lemonfiend via Digitalmars-d-learn
linearRemove is linear, so I think it accepts a range. Perhaps 
the "once" range is enough.

I cannot find once in the docs. Did you mean std.range.only?

Error: function std.container.SList!(Tree).SList.linearRemove 
(Range r) is not callable using argument types (OnlyResult!(Tree, 
1u))


Re: import except one?

2014-06-26 Thread sigod via Digitalmars-d-learn

```
import std.process : Config_ = Config;
```


Re: import except one?

2014-06-26 Thread sigod via Digitalmars-d-learn

Sorry, wrong one.

There seems no solution for this. So, you must use fully 
qualified name.


Re: SList: How do I use linearRemove?

2014-06-26 Thread sigod via Digitalmars-d-learn

Take a look at unittests in [std.container.slist][0]:

```
unittest
{
auto s = SList!int(1, 2, 3, 4, 5);
auto r = s[];
popFrontN(r, 3);
auto r1 = s.linearRemove(r);
assert(s == SList!int(1, 2, 3));
assert(r1.empty);
}

unittest
{
auto s = SList!int(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
auto r = s[];
popFrontN(r, 3);
auto r1 = take(r, 4);
assert(equal(r1, [4, 5, 6, 7]));
auto r2 = s.linearRemove(r1);
assert(s == SList!int(1, 2, 3, 8, 9, 10));
assert(equal(r2, [8, 9, 10]));
}
```

[0]: 
https://github.com/D-Programming-Language/phobos/blob/master/std/container/slist.d#L575


Re: Assosiative array pop

2014-06-26 Thread Meta via Digitalmars-d-learn

On Thursday, 26 June 2014 at 09:21:28 UTC, seany wrote:

On Wednesday, 25 June 2014 at 14:17:50 UTC, Meta wrote:

If you want something like a hash table that preserves 
insertion order, you could try using an array of tuples 
instead. Then to "pop" the first element, just do 'arr = 
arr[1..$]'.


Thank you, this is _exactly_ what I was looking for! Thank you 
so

much!


Keep in mind that it will be up to you to ensure that each value 
only exists in the array once.


Re: import except one?

2014-06-26 Thread sigod via Digitalmars-d-learn

Dirty solution:

```
import scriptlike;
import your_module;
import your_module : Config;
```

So, `Config` from your module will override one from scriptlike.


Re: Is their a way for a Child process to modify its Parent's environment?

2014-06-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tue, 24 Jun 2014 21:53:51 -0400, WhatMeWorry   
wrote:



I open a command line window, and run the following 6 line program

void main()
{
string envPath = environment["PATH"];

writeln("PATH is: ", envPath);

envPath ~= r";F:\dmd2\windows\bin";

environment["PATH"] = envPath;

envPath = environment["PATH"];

writeln("PATH is: ", envPath);

}

It prints out the following

PATH is: C:\Windows\system32;C:\Windows...
PATH is: C:\Windows\system32;C:\Windows...F:\dmd2\windows\bin

when the program exits, I'm back at the command line and I do a

echo %PATH%

which just shows C:\Windows\system32;C:\Windows...

Anybody know of a way to make the change stick for the lifetime of the
command window?


Only the command shell can change it's own environment. When you execute  
commands that set an environment variable, those are shell builtins, not  
external programs.


You can run a batch file (which is not run in a separate process) which  
sets environment variables. This may be the only way to affect the  
environment. Basically, have a program run that dictates what to set,  
builds a batch file, then run that batch file from the command line. This  
could be done in another batch file.


-Steve


Re: Using attributes inside template instantiation

2014-06-26 Thread Meta via Digitalmars-d-learn

On Thursday, 26 June 2014 at 07:11:03 UTC, Uranuz wrote:

But if I write

@("hello") struct Hello {}

so all of the variables that have type Hello will have 
attribute @("hello") like come type qualifier because attribute 
is a part of declaration of Hello. Do I understand correctly?


No, it is only the symbol Hello that will have the attribute 
@("hello"). Attributes are attached to symbols, not types or 
values.


httpS post fail at tango

2014-06-26 Thread JJDuck via Digitalmars-d-learn

I use Tango's example from
http://www.dsource.org/projects/tango/docs/stable/

// open a web-page for posting (see HttpGet for simple reading)
auto post = new HttpPost ("http://yourhost/yourpath";);

// send, retrieve and display response
Cout (cast(char[]) post.write("posted data", "text/plain"));


but it cannot post to a http's' address.

Can anyone advise me, i cannot find any other information online.

Thanks


Re: SList: How do I use linearRemove?

2014-06-26 Thread Lemonfiend via Digitalmars-d-learn

unittest
{
auto s = SList!int(1, 2, 3, 4, 5);
auto r = s[];
popFrontN(r, 3);
auto r1 = s.linearRemove(r);
assert(s == SList!int(1, 2, 3));
assert(r1.empty);
}


This works:
auto s = SList!int(1, 2, 3, 4, 5);
auto r = s[];
popFrontN(r, 1);
auto r1 = s.linearRemove(r);

This doesn't (why?):
auto s = SList!int(1, 2, 3, 4, 5);
auto r = s[];
auto r1 = s.linearRemove(r);

This doesn't (why?):
auto s = SList!int(1, 2, 3, 4, 5);
auto s2 = SList!int(1, 2, 3, 4, 5);
auto r = s2[];
popFrontN(r, 1);
auto r1 = s.linearRemove(r);

I am at a loss..


Re: httpS post fail at tango

2014-06-26 Thread JJDuck via Digitalmars-d-learn

On Thursday, 26 June 2014 at 16:33:57 UTC, JJDuck wrote:


I tried to use phobos , but there is no such function exists for 
posting to https too




Getting libcurl for 64 bit Windows

2014-06-26 Thread Mark Isaacson via Digitalmars-d-learn

I am attempting to make use of std.net.curl and having trouble
acquiring libcurl for 64 bit Windows. I need to be able to link
with the MSVC linker (which happens to be the default when
compiling using dmd with -m64). I've looked on the libcurl
website and not found any downloads that look promising.

I've tried following the instructions at:
http://wiki.dlang.org/Curl_on_Windows#Building_libcurl_64_bit

But when I compile the dll with: "dmd main.d -m64 -Llibcurl.dll"
I get the linker error:
libcurl.dll : fatal error LNK1107: invalid or corrupt file:
cannot read at 0x330

Might anyone have an idea as to how to resolve this?


Re: Getting libcurl for 64 bit Windows

2014-06-26 Thread Mark Isaacson via Digitalmars-d-learn

Managed to build it successfully I think, but have actually
returned to the problem that initially caused me to want to try
and build the library in the first place:

If I try to build a simple program:

import std.stdio;
import std.net.curl;

void main() {
   writeln("Hello world");
}

The program compiles, but does not print Hello World at
runtime... it just stops, and seemingly does nothing.

Trying to determine the root cause of that now.


Re: Getting libcurl for 64 bit Windows

2014-06-26 Thread Andrei Alexandrescu via Digitalmars-d-learn

On 6/26/14, 11:11 AM, Mark Isaacson wrote:

Managed to build it successfully I think, but have actually
returned to the problem that initially caused me to want to try
and build the library in the first place:

If I try to build a simple program:

import std.stdio;
import std.net.curl;

void main() {
writeln("Hello world");
}

The program compiles, but does not print Hello World at
runtime... it just stops, and seemingly does nothing.

Trying to determine the root cause of that now.


Mark is my intern, and we're currently blocked by this in creating an 
important demo for tomorrow.


Does anyone have good instructions for building libcurl on Win64, or 
prebuild .lib and .dll files?



Thanks very much,

Andrei


Re: SList: How do I use linearRemove?

2014-06-26 Thread sigod via Digitalmars-d-learn

First case is a bug. I'll make pull request.
Not sure about second.


Re: Getting libcurl for 64 bit Windows

2014-06-26 Thread Mark Isaacson via Digitalmars-d-learn

Resolved the issue.


Re: Getting libcurl for 64 bit Windows

2014-06-26 Thread Brad Roberts via Digitalmars-d-learn

The one that the win64 auto-tester uses is here:

http://downloads.dlang.org/other/
curl-7.28.1-devel-rainer.win64.zip

There's a newer one available there, but I can't vouch for it.


On 6/26/14, 11:49 AM, Andrei Alexandrescu via Digitalmars-d-learn wrote:

On 6/26/14, 11:11 AM, Mark Isaacson wrote:

Managed to build it successfully I think, but have actually
returned to the problem that initially caused me to want to try
and build the library in the first place:

If I try to build a simple program:

import std.stdio;
import std.net.curl;

void main() {
writeln("Hello world");
}

The program compiles, but does not print Hello World at
runtime... it just stops, and seemingly does nothing.

Trying to determine the root cause of that now.


Mark is my intern, and we're currently blocked by this in creating an important 
demo for tomorrow.

Does anyone have good instructions for building libcurl on Win64, or prebuild 
.lib and .dll files?


Thanks very much,

Andrei


Re: import except one?

2014-06-26 Thread Puming via Digitalmars-d-learn

On Thursday, 26 June 2014 at 16:02:15 UTC, sigod wrote:

Dirty solution:

```
import scriptlike;
import your_module;
import your_module : Config;
```

So, `Config` from your module will override one from scriptlike.


I'm currenly renaming my own symbol:

```d
import scriptlike;
import config : Cfg = Config;
```

Your solution works for me  :-)

Thanks


Re: import except one?

2014-06-26 Thread Puming via Digitalmars-d-learn

On Thursday, 26 June 2014 at 08:02:24 UTC, bearophile wrote:

Puming:

I'm using scriptlike, which imports everything from 
std.process for convienience, but I also need to import 
another module, which contains a class `Config`, it conflicts 
with std.process.Config. I don't actually need 
std.process.Config, but I need many other symbols in 
scriptlike and std.process.


What I want to achieve is to import ALL symbols from 
scriptlike EXCEPT std.process.Config, something like:


```d
import scriptlike: !Config;


A similar idea is present in Haskell, but it was refused by 
Walter.


Thanks :-)

I wander what was the rationale behind Walter's rejection.  IMHO 
if we have a selective filter mechanism for imports, the 
complement exclude mechinism works as well.


But of cause we are not that far yet, final, nothrow, pure and 
others don't have their complements either.




The use of scriptlike is going to cause you similar problems, 
it's not for a fine tuning of imports.


The problem is that we don't have a complete mechanism to fine 
tuning the imports. Selective filtering is only half of the cake.




Bye,
bearophile




~ ?

2014-06-26 Thread pgtkda via Digitalmars-d-learn

What does this symbol mean in relation to D?

~


Enum type deduction inside templates is not working

2014-06-26 Thread Uranuz via Digitalmars-d-learn
Compiler can't deduce type for template struct Pair when using it 
with enum argument.  There is an example


import std.stdio;

enum Category { first, second, third };

struct Pair(F, S)
{
F first;
S second;

this(F f, S s)
{
first = f;
second = s;
}
}


void main()
{
auto p = Pair(Category.first, "first"); //It fails

writeln(p);
}

Is it not working for some reason or I'm doing something wrong or 
is it just lack of implementation? How I could make this working 
without explicit specifying of types?


Re: Enum type deduction inside templates is not working

2014-06-26 Thread pgtkda via Digitalmars-d-learn

On Friday, 27 June 2014 at 06:12:57 UTC, pgtkda wrote:
How I could make this

working without explicit specifying of types?


sorry, i should read better




Re: Enum type deduction inside templates is not working

2014-06-26 Thread pgtkda via Digitalmars-d-learn

On Friday, 27 June 2014 at 06:04:20 UTC, Uranuz wrote:
Compiler can't deduce type for template struct Pair when using 
it with enum argument.  There is an example


import std.stdio;

enum Category { first, second, third };

struct Pair(F, S)
{
F first;
S second;

this(F f, S s)
{
first = f;
second = s;
}
}


void main()
{
auto p = Pair(Category.first, "first"); //It fails

writeln(p);
}

Is it not working for some reason or I'm doing something wrong 
or is it just lack of implementation? How I could make this 
working without explicit specifying of types?


is this a solution for your problem?


enum Category { first, second, third };

struct Pair
{
Category cat;
string second;
this(Category cat, string second){
this.cat = cat, this.second = second;
}
}
void main(){
auto p = Pair(Category.first, "first");
writeln(p);
}



Re: Enum type deduction inside templates is not working

2014-06-26 Thread Uranuz via Digitalmars-d-learn

On Friday, 27 June 2014 at 06:14:48 UTC, pgtkda wrote:

On Friday, 27 June 2014 at 06:12:57 UTC, pgtkda wrote:
How I could make this

working without explicit specifying of types?


sorry, i should read better


Ok. Maybe it was discussed already somewhere, but I am not god in 
searching in English. Is there any directions about it? How could 
I work around it? Should I mail some proposal or bug report for 
it?


Re: ~ ?

2014-06-26 Thread Ali Çehreli via Digitalmars-d-learn

On 06/26/2014 10:58 PM, pgtkda wrote:

What does this symbol mean in relation to D?

~


It can be used in two ways:

1) When used as a unary operator, it means bitwise complement:

assert(~0xaa55aa55 == 0x55aa55aa);

2) When used as a binary operator, it means concatenation:

assert("hello" ~ " world" == "hello world");

auto arr = [ 1, 2 ];
assert(arr ~ 3 == [ 1, 2, 3 ]);

When used with assignment, it means appending:

auto arr = [ 1, 2 ];
arr ~= 3;

assert(arr == [ 1, 2, 3 ]);

It can also be used in the special function name ~this(), which is the 
destructor of a struct or a class. (Related functions: 'static ~this()' 
and 'shared static ~this()')


Ali

[1] http://ddili.org/ders/d.en/bit_operations.html

[2] http://ddili.org/ders/d.en/arrays.html

[3] ddili.org/ders/d.en/special_functions.html



Re: Enum type deduction inside templates is not working

2014-06-26 Thread pgtkda via Digitalmars-d-learn

On Friday, 27 June 2014 at 06:21:11 UTC, Uranuz wrote:

On Friday, 27 June 2014 at 06:14:48 UTC, pgtkda wrote:

On Friday, 27 June 2014 at 06:12:57 UTC, pgtkda wrote:
How I could make this

working without explicit specifying of types?


sorry, i should read better


Ok. Maybe it was discussed already somewhere, but I am not god 
in searching in English. Is there any directions about it? How 
could I work around it? Should I mail some proposal or bug 
report for it?


I think, D is a typesafe language, therefore you can't use 
variables with no type declaration.


One thing you can search for, are templates but even there you 
have to define a type:


import std.stdio;

enum Category : string { first = "first"}

template Pair(T)
{
T t;
T cat;
}


void main()
{
alias Pair!(string) a;
a.cat = Category.first;
a.t = "first";

writeln(a.cat, " . ", a.t);
}


Re: ~ ?

2014-06-26 Thread pgtkda via Digitalmars-d-learn

On Friday, 27 June 2014 at 06:33:07 UTC, Ali Çehreli wrote:

On 06/26/2014 10:58 PM, pgtkda wrote:

What does this symbol mean in relation to D?

~


It can be used in two ways:

1) When used as a unary operator, it means bitwise complement:

assert(~0xaa55aa55 == 0x55aa55aa);

2) When used as a binary operator, it means concatenation:

assert("hello" ~ " world" == "hello world");

auto arr = [ 1, 2 ];
assert(arr ~ 3 == [ 1, 2, 3 ]);

When used with assignment, it means appending:

auto arr = [ 1, 2 ];
arr ~= 3;

assert(arr == [ 1, 2, 3 ]);

It can also be used in the special function name ~this(), which 
is the destructor of a struct or a class. (Related functions: 
'static ~this()' and 'shared static ~this()')


Ali

[1] http://ddili.org/ders/d.en/bit_operations.html

[2] http://ddili.org/ders/d.en/arrays.html

[3] ddili.org/ders/d.en/special_functions.html


Thanks :)