Re: Embedded Containers

2017-12-05 Thread John Chapman via Digitalmars-d
On Tuesday, 5 December 2017 at 19:01:48 UTC, A Guy With a 
Question wrote:

The following doesn't appear to be valid syntax. Array!Item!T

I get the following error:

"multiple ! arguments are not allowed"

Which is ok...I get THAT error, however, this does not work 
either:


alias Items(T) = Array!Item(T);

This gives me the error:

Error: function declaration without return type. (Note that 
constructors are always named `this`)	


Your wrapping the wrong part in parentheses.

  Array!(Item!T)

It would actually be Array!(Item!(T)), but if a single type is 
specified you're allowed to omit the parentheses when 
instantiating.




Item is defined as follows:

interface Item(T)
{
   @property
   T member();
}

That part compiles fine. However, even when I remove the 
aliasing, I can't import this interface. I get "Error: 
undefined identifier 'Item'"


I'm not quite sure I understand how to create a generic 
container interface or class in D. Half of how I expect it to 
work works, but the other half doesn't. The docs aren't too 
helpful. I'm not sure if it's a case where there's just too 
much to go through or if what I'm trying to do isn't really 
covered. Essentially I'm trying to create an array of this type 
'Item' that has some generic members. I think people who come 
from C# will kind of get what I'm trying to do here, because 
I'm trying to port C# code.


What other problems are you having? I did the same and it was 
fairly straightforward.




Re: DMD VS2017 Support

2017-04-30 Thread John Chapman via Digitalmars-d

On Sunday, 30 April 2017 at 16:05:10 UTC, Igor wrote:

On Sunday, 30 April 2017 at 15:53:07 UTC, Mike Parker wrote:

On Sunday, 30 April 2017 at 14:56:44 UTC, Igor wrote:



I tried updating sc.ini to new paths but I still get this 
error. Can someone offer some advice?


Which paths did you set?


These are the ones I changed:

VCINSTALLDIR=C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Community\VC\Tools\MSVC\14.10.25017\

UCRTVersion=10.0.15063.0

LINKCMD=%VCINSTALLDIR%\bin\HostX64\x64\link.exe

PATH=%PATH%;%VCINSTALLDIR%\bin\HostX64\x64

LIB=%LIB%;"%VCINSTALLDIR%\lib\x64"

Same for x86 environment, except, of course I replaced x64 with 
x86 in the values.


I should also mention that compiling using DUB works. It only 
doesn't work from VS.


Here are mine, if it helps:

VCINSTALLDIR=C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Community\VC

WindowsSdkDir=C:\Program Files (x86)\Windows Kits\10
UniversalCRTSdkDir=C:\Program Files (x86)\Windows Kits\10
UCRTVersion=10.0.15063.0
LINKCMD=%VCINSTALLDIR%\Tools\MSVC\14.10.25017\bin\HostX64\x64\link.exe
PATH=%PATH%;%VCINSTALLDIR%\Tools\MSVC\14.10.25017\bin\HostX64\x64
LIB=%LIB%;"%VCINSTALLDIR%\Tools\MSVC\14.10.25017\lib\x64"
LIB=%LIB%;"%UniversalCRTSdkDir%\Lib\%UCRTVersion%\um\x64"
LIB=%LIB%;"%UniversalCRTSdkDir%\Lib\%UCRTVersion%\ucrt\x64"



Re: DMD on WIndows 10

2015-08-01 Thread John Chapman via Digitalmars-d

On Friday, 31 July 2015 at 22:02:13 UTC, Paul D Anderson wrote:
I'm waiting to upgrade from Windows 7 to Windows 10 to avoid 
the inevitable just-released bugs, but does anyone have any 
info about D on Windows 10? Has anyone tried it?


I'm on Windows 10, and my DMD-built programs run just fine.


Re: New names - 2.068 roundup

2015-06-24 Thread John Chapman via Digitalmars-d

On Wednesday, 24 June 2015 at 01:04:01 UTC, Adam D. Ruppe wrote:

The code breakage is minimal


Won't this break isSomeString? Phobos uses this everywhere.


Re: Naming things

2015-06-22 Thread John Chapman via Digitalmars-d

On Monday, 22 June 2015 at 11:45:31 UTC, Wyatt wrote:
 None of the suggestions I've seen so far really call out to me 
"hey, this is lazy and has a non-lazy counterpart".  Would it 
be so wrong to add "lazy" to the beginning or end so it's super 
obvious at a glance with zero cognitive overhead?


-Wyatt


This would be my preferred option. When C# introduced 
asynchronous counterparts of existing methods, they appended 
"Async" to the names, which seems to have worked out well - eg, 
Wait/WaitAsync, Read/ReadAsync. So we'd have 
setExtension/setExtensionLazy etc.


Re: DIP80: phobos additions

2015-06-10 Thread John Chapman via Digitalmars-d
On Wednesday, 10 June 2015 at 09:30:37 UTC, Robert burner Schadek 
wrote:

On Wednesday, 10 June 2015 at 09:12:17 UTC, John Chapman wrote:


Logging


std.experimental.logger!?


Perfect, he said sheepishly.


Re: DIP80: phobos additions

2015-06-10 Thread John Chapman via Digitalmars-d

On Wednesday, 10 June 2015 at 07:56:46 UTC, John Chapman wrote:
It's a shame ucent/cent never got implemented. But couldn't 
they be added to Phobos? I often need a 128-bit type with 
better precision than float and double.


Other things I often have a need for:

Weak references
Queues, stacks, sets
Logging
Custom date/time formatting
Locale-aware number/currency formatting
HMAC (for OAuth)
URI parsing
Sending email (SMTP)
Continuations for std.parallelism.Task
Database connectivity (sounds like this is on the cards)
HTTP listener


Re: DIP80: phobos additions

2015-06-10 Thread John Chapman via Digitalmars-d
It's a shame ucent/cent never got implemented. But couldn't they 
be added to Phobos? I often need a 128-bit type with better 
precision than float and double.


Re: core.thread.[Ss]leep - Is this a bug?

2015-05-13 Thread John Chapman via Digitalmars-d

On Wednesday, 13 May 2015 at 20:09:44 UTC, wobbles wrote:

On windows,
core.thread.Sleep  (big 'S')

On linux
core.thread.sleep  (little 'S')


I'm trying to import as little symbols as possible, so was 
importing specific items like

import core.thread : Sleep;

but it fails when I compile on linux, so I need to do a
version(Windows) import core.thread : Sleep;
version(Posix) import core.thread : sleep;

Seems like a bug?


No, you should be calling Thread.sleep (capital T) instead.


DMD compiler platform documentation AWOL

2015-01-25 Thread John Chapman via Digitalmars-d
Looks like the documentation for DMD's command line switches and 
platform-specific information has disappeared from the site. It 
used to live under "Downloads & Tools" in menus labelled "Linux 
notes", "Windows notes" etc.


Thread name conflict

2014-05-05 Thread John Chapman via Digitalmars-d
Importing both core.thread and std.regex results in a conflict as 
both define a Thread type.


Perhaps the regex module's author assumed there'd be no clash 
since it's a template - Thread(DataIndex). Should I file a bug 
suggesting a name change? Or maybe D ought to allow both 
parameterised and normal types to have the same name - C# for 
example allows it.


Re: now I didn't have RegisterClassExW, how to import that ?

2013-01-27 Thread John Chapman

On Sunday, 27 January 2013 at 19:29:03 UTC, John Chapman wrote:

On Sunday, 27 January 2013 at 18:58:59 UTC, rsk82 wrote:

On Sunday, 27 January 2013 at 18:26:04 UTC, John Chapman wrote:

This must be declared at module level (not inside a function).


Ok, I've put it into module, linked in the module
pragma(lib, "user32.lib");
and
pragma(lib, "gdi32.lib");

all this works until I put

extern(Windows) ATOM RegisterClassExW(const WNDCLASSEXW 
*lpwcx);


on line 30, then I get as if this was a code not a new 
function import:


.\mod\myModule.d(30): Error: undefined identifier WNDCLASSEXW, 
did you mean struct WNDCLASSEXA?


Because WNDCLASSEXW is not defined. So define it above 
RegisterClassExW.


struct WNDCLASSEXW {
  UINT  cbSize = WNDCLASSEXW.sizeof;
  UINT  style;
  WNDPROC   lpfnWndProc;
  int   cbClsExtra;
  int   cbWndExtra;
  HINSTANCE hInstance;
  HICON hIcon;
  HCURSOR   hCursor;
  HBRUSHhbrBackground;
  LPCTSTR   lpszMenuName;
  LPCTSTR   lpszClassName;
  HICON hIconSm;
}


Actually, replace "LPCTSTR" above with "LPCWSTR".


Re: now I didn't have RegisterClassExW, how to import that ?

2013-01-27 Thread John Chapman

On Sunday, 27 January 2013 at 18:58:59 UTC, rsk82 wrote:

On Sunday, 27 January 2013 at 18:26:04 UTC, John Chapman wrote:

This must be declared at module level (not inside a function).


Ok, I've put it into module, linked in the module
pragma(lib, "user32.lib");
and
pragma(lib, "gdi32.lib");

all this works until I put

extern(Windows) ATOM RegisterClassExW(const WNDCLASSEXW *lpwcx);

on line 30, then I get as if this was a code not a new function 
import:


.\mod\myModule.d(30): Error: undefined identifier WNDCLASSEXW, 
did you mean struct WNDCLASSEXA?


Because WNDCLASSEXW is not defined. So define it above 
RegisterClassExW.


struct WNDCLASSEXW {
  UINT  cbSize = WNDCLASSEXW.sizeof;
  UINT  style;
  WNDPROC   lpfnWndProc;
  int   cbClsExtra;
  int   cbWndExtra;
  HINSTANCE hInstance;
  HICON hIcon;
  HCURSOR   hCursor;
  HBRUSHhbrBackground;
  LPCTSTR   lpszMenuName;
  LPCTSTR   lpszClassName;
  HICON hIconSm;
}


Re: now I didn't have RegisterClassExW, how to import that ?

2013-01-27 Thread John Chapman

On Sunday, 27 January 2013 at 18:01:38 UTC, rsk82 wrote:
On Sunday, 27 January 2013 at 17:51:40 UTC, Benjamin Thaut 
wrote:

extern(Windows) 


I am not sure what I was supposed to do, so I did this:

extern(Windows) ATOM RegisterClassExW(const WNDCLASSEXW *lpwcx);


This must be declared at module level (not inside a function).


ATOM class_atom = RegisterClassExW(&wc);

and got linker error:

OPTLINK (R) for Win32  Release 8.00.12
Copyright (C) Digital Mars 1989-2010  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
test.obj(test)
 Error 42: Symbol Undefined 
__D4test8doWindow6__ctorMFZC4test8doWindow16RegisterClassExWWxPS4test8doWindow6__ctorMFZC4test8doWindow11WNDCLASSEXWZt@4

--- errorlevel 1




Re: 2 problems I can't get my head around

2012-11-26 Thread John Chapman

On Monday, 26 November 2012 at 15:39:35 UTC, Manu wrote:

On 26 November 2012 14:31, Manu  wrote:


1.

enum i = 10;
pragma(msg, is(i == enum) || is(typeof(i) == enum)); // <- 
false?!


I can't find a way to identify that i is an enum, not a 
variable; can not

be assigned, has no address, etc.


2.

import std.stdio;
pragma(msg, !is(std) && is(typeof(std))); // <- true?!

std.stdio is a module, it looks like a variable. typeof(std) 
== void...

What the? Why does it even have a type?
I can't find a sensible way to distinguish std from any other 
regular

variable.



And a new one!

3.

Properties look like variables. How do I distinguish properties 
from proper

variables?
struct S
{
  @property int P() { return 10; }
}

pragma(msg, is(typeof(S.P) == function)) // false?!


http://dlang.org/phobos/std_traits.html#functionAttributes


Re: 2 problems I can't get my head around

2012-11-26 Thread John Chapman

On Monday, 26 November 2012 at 12:32:08 UTC, Manu wrote:

1.

enum i = 10;
pragma(msg, is(i == enum) || is(typeof(i) == enum)); // <- 
false?!


I can't find a way to identify that i is an enum, not a 
variable; can not

be assigned, has no address, etc.


Because 'i' is not an enum, it's actually a manifest constant. 
Unless you specify an enum name, no new type is created. 
http://dlang.org/enum.html


Compare:

enum E {
 i = 10
}
pragma(msg, is(typeof(E.i) == enum));



Re: [ ArgumentList ] vs. @( ArgumentList )

2012-11-07 Thread John Chapman

On Wednesday, 7 November 2012 at 16:55:23 UTC, Marco Leise wrote:

Am Wed, 07 Nov 2012 09:19:41 +0100
schrieb "John Chapman" :


> [ ArgumentList ]
>
> Pros:
> precedent with C#

And Delphi.


That adds to the user base, but it is possible that in both
cases Anders Hejlsberg was responsible for the design
decision, making it more like a CDelphi# feature. :)


Actually, C# got there first, Delphi not until 2010.


Re: [ ArgumentList ] vs. @( ArgumentList )

2012-11-07 Thread John Chapman
On Wednesday, 7 November 2012 at 11:29:16 UTC, Simen Kjaeraas 
wrote:

On 2012-12-07 11:11, Timon Gehr  wrote:


On 11/07/2012 09:28 AM, Simen Kjaeraas wrote:
On 2012-19-07 09:11, John Chapman  
wrote:



Personally, I also like .


I am glad to say this will not happen. <> as delimiters cause 
problems

because they're used elsewhere as non-matching:

 bar)>



This example does not show that they cause problems.


Not true. The compiler certainly can handle it, but a 
programmer could

easily be confused.


I'm not putting it forward for consideration, but there is a 
precedent in Visual Basic - 
http://msdn.microsoft.com/en-US/library/h3z05kek%28v=vs.80%29.aspx


Re: [ ArgumentList ] vs. @( ArgumentList )

2012-11-07 Thread John Chapman

[ ArgumentList ]

Pros:
precedent with C#


And Delphi.


@( ArgumentList )

Pros:
looks like existing @attribute syntax
no parsing problems

Cons:
not as nice looking


@ArgumentList makes me think I'm on Twitter. #joke

Personally, I also like . Prior to @property and 
family being introduced, I'd have gone with [ArgumentList]. But 
since @ is the prefix for attributes in D, let's stick with it 
for UDAs.


And as to any clashes between UDAs and possible future built-in 
ones, I'd say the language has first dibs on names and it's up to 
people writing UDAs to avoid using names that sound like language 
constructs.


Re: Uri class and parser

2012-10-26 Thread John Chapman

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.


Re: Vote for std.uuid

2012-06-19 Thread John Chapman

On Tuesday, 19 June 2012 at 11:24:50 UTC, Dmitry Olshansky wrote:
As been mentioned previously, std.uuid is quite small so we've 
settled for shorter review period. That period ended as of some 
hours ago.


It's time to start voting on its inclusion into Phobos. The 
voting ends at 25-26 June.


---
Code: https://github.com/jpf91/phobos/blob/std.uuid/std/uuid.d
API-Docs: http://dl.dropbox.com/u/24218791/d/src/uuid.html
---


Yes.

Just a note on the documentation: replace "an UUID" with "a UUID".


Re: Same _exact_ code in C and D give different results — why?

2012-06-04 Thread John Chapman

On Monday, 4 June 2012 at 17:52:10 UTC, Mehrdad wrote:

On Monday, 4 June 2012 at 16:37:45 UTC, Kagamin wrote:

On Monday, 4 June 2012 at 13:58:22 UTC, Mehrdad wrote:

(@Andrej Mitrovic, mainly)

So I was using your library :) and this happened:

http://stackoverflow.com/questions/10878586

Any ideas?


You need to specify subsystem 4.0 or something like that, 
google for .def file docs on dmc site.


I don't think that's the issue -- the subsystems for the C code
is Console.


Yes, but it defaults to 3.10 - you need to specify 4 or higher.

-L/SUBSYSTEM:Console:4


Re: [Proposal] Additional operator overloadings for multidimentional indexing and slicing

2012-06-04 Thread John Chapman

On Monday, 4 June 2012 at 10:00:20 UTC, Dmitry Olshansky wrote:

On 04.06.2012 13:57, Don Clugston wrote:

On 03/06/12 19:31, tn wrote:

On Friday, 1 June 2012 at 01:57:36 UTC, kenji hara wrote:

I'd like to propose a new language feature to D community.
...
This patch is an additional enhancement of opDollar (issue 
3474 and

#442).



Sounds awesome. However, the name opDollar should be changed 
to

something like opSize, opLength, opEnd or almost anything else
than the current name.


opDollar is a pretty awful name but nobody could come up with 
something
that is less awful. At least it is not confusing. Everybody 
instantly

knows what it does.
For built-in arrays $ is the length and the size, but that 
isn't

generally true.

Wish we had a better name, but opLength isn't it, and nor is 
opSize.
opEnd might be the best of those three, but it kinda sounds 
like

something to do with ranges.


opEndSymbol ? It's no dollar but it's clear what it overloads.


Maybe opUpperBound or opUBound?


Re: SetTimer function not found?

2012-06-02 Thread John Chapman

On Saturday, 2 June 2012 at 10:35:17 UTC, Kevin Cox wrote:
On Jun 2, 2012 6:33 AM, "John Chapman" 
 wrote:


On Saturday, 2 June 2012 at 10:11:02 UTC, Godlike wrote:


On Saturday, 2 June 2012 at 10:00:07 UTC, Martin Nowak wrote:


Just add these declarations to the appropriate module:

extern(Windows) {

alias void function(HWND, uint, uint, uint) TIMERPROC;

uint SetTimer(HWND hWnd, uint uIDEvent, uint uElapse, TIMERPROC

lpTimerFunc);


BOOL KillTimer(HWND hWnd, uint uIDEvent);
}


Better yet, put them into std.windows and submit a pull request 
:P


Done.


Re: SetTimer function not found?

2012-06-02 Thread John Chapman

On Saturday, 2 June 2012 at 10:47:37 UTC, Dmitry Olshansky wrote:

On 02.06.2012 14:35, Kevin Cox wrote:


On Jun 2, 2012 6:33 AM, "John Chapman" mailto:johnch_a...@hotmail.com>> wrote:
>
> On Saturday, 2 June 2012 at 10:11:02 UTC, Godlike wrote:
>>
>> On Saturday, 2 June 2012 at 10:00:07 UTC, Martin Nowak
wrote:
>
> Just add these declarations to the appropriate module:
>
> extern(Windows) {
>
> alias void function(HWND, uint, uint, uint) TIMERPROC;


Better check this callback definition - it might be 
extern(System) or extern(C).


No, it's extern(Windows). And actually it's already defined in 
core.sys.windows.windows.





>
> uint SetTimer(HWND hWnd, uint uIDEvent, uint uElapse,
TIMERPROC
lpTimerFunc);
>
> BOOL KillTimer(HWND hWnd, uint uIDEvent);
> }

Better yet, put them into std.windows and submit a pull 
request :P





Re: SetTimer function not found?

2012-06-02 Thread John Chapman

On Saturday, 2 June 2012 at 10:11:02 UTC, Godlike wrote:

On Saturday, 2 June 2012 at 10:00:07 UTC, Martin Nowak wrote:
On Sat, 02 Jun 2012 11:46:39 +0200, Godlike 
 wrote:



Hi

Im experiencing problems with writing a windows program in D 
language, it's really good language width C++ speed and C# 
easy of use but why there's no critically important for 
windows programmers function SetTimer? Is there a 
reimplementation or something?


Regards




I cant manage it to work, compiled it but conflict errors on 
import. I really need this function otherwise im cooked.


Just add these declarations to the appropriate module:

extern(Windows) {

alias void function(HWND, uint, uint, uint) TIMERPROC;

uint SetTimer(HWND hWnd, uint uIDEvent, uint uElapse, TIMERPROC 
lpTimerFunc);


BOOL KillTimer(HWND hWnd, uint uIDEvent);
}


Re: Easiest way to get GUI

2012-05-31 Thread John Chapman

On Thursday, 31 May 2012 at 12:13:31 UTC, Gor Gyolchanyan wrote:
Can anyone please tell me what's the easiest way to get a GUI 
library?


Some UI libraries are listed over on the Wiki: 
http://prowiki.org/wiki4d/wiki.cgi?GuiLibraries


Re: clear() and UFCS

2012-05-25 Thread John Chapman

On Friday, 25 May 2012 at 20:16:32 UTC, Brad Anderson wrote:

On Fri, May 25, 2012 at 1:34 PM, sclytrack 

blank, destroy, trash, dump, zero, bleach, cleanup,
sanitize, burn, nuke, eject, jetisson, discard,
landfill, waste, litter, debris, recycle, obliterate,
annihilate, eradicate, expunge, finish, ravage, wipe,
zap, abolish, decimate, demolish, massacre, murder,
ruin, slaughter, quash, scrub, splat




I'm partial to defenestrate().


One for the Doctor Who fans among us:

exterminate().


Re: Defining a custom *constructor* (not initializer!)

2012-05-12 Thread John Chapman
Yup, they do what C# does with the constructor: they put make a 
*separate* function, createHandle(), used to create the control.


And they simply *don't* tie the destructor to DestroyWindow(); 
instead, they just assume the user will call dispose().>
So in other words, they just ignored the entire problem with 
the lifetimes, and hoped ("required"?) that the user will call 
dispose().


Actually, in WinForms, closing the application's main Form
triggers its Dispose method, which disposes of child Controls too.


Memoize and protected functions

2012-05-12 Thread John Chapman
Functions you want to memoize have to be visible to 
std.functional.memoize, so it only works with public functions. 
Is this a bug or merely a bugbear?


Re: Does D have too many features?

2012-04-30 Thread John Chapman

On Monday, 30 April 2012 at 07:49:48 UTC, simendsjo wrote:


I use it to "fake" object initializers from C#: 
http://msdn.microsoft.com/en-us/library/bb384062.aspx

A feature I love in C# and would like to see in D.


Ooh, nice - care to share?


Re: Windows 8 Metro support

2012-04-10 Thread John Chapman

On Tuesday, 10 April 2012 at 07:24:09 UTC, Sönke Ludwig wrote:
But one thing in particular, that you are not allowed to do is 
to use kernel32.dll (at least I was told). So you still have to 
rewrite all the C-library functions (such as fopen(), malloc() 
and so on) and anything that the D runtime or Phobos uses from 
kernel32 or similar libraries; I gues the same applies to 
ws2_32 and so on.


Not strictly true. Here's the subset of the Win32 API that can be 
used in Metro apps: 
http://msdn.microsoft.com/en-us/library/windows/apps/br205757.aspx


Re: Anonymous function syntax

2011-09-24 Thread John Chapman
== Quote from Jonathan M Davis (jmdavisp...@gmx.com)'s article
> On Friday, September 23, 2011 23:42:52 Andrei Alexandrescu wrote:
> > On 9/23/11 8:03 PM, Martin Nowak wrote:
> > > On Thu, 22 Sep 2011 22:54:55 +0200, Andrei Alexandrescu
> > >  wrote:
> > > I want to add some points against introducing this particular syntax.
> > >
> > > 1. Foremost using '=>' is unfamiliar. Comming from C++ or Java you
> > > really have to learn reading it.
> > > If you weighted the lambda syntaxes with the tiobe factor, arrows would
> > > be a minority.
> >
> > Well the C++2011 lambda syntax is quite foreign for C++ users, too.
> And Andrei's suggested syntax is very similar to C#'s lambda syntax, so it
> _is_ a syntax familiar to some of the programmers who use a major language
> derived from C++. It's certainly going to be more familiar than the syntax of
> any of the functional languages out there.

Java's adopting the C# syntax for its lambdas too.
http://java.dzone.com/news/java-8-lambda-syntax-decided

And is it that hard to learn?