In Expression for Static and DYnamic Arrays

2012-10-12 Thread Rizo Isrof
Hi, 

Why the `in` expression can only be applied to associative
arrays and cannot be used with static or dynamic arrays as
it is possible with, _e.g._, Python?

The following code is not legal:

int[] a = [1,2,3,4,5];
if (1 in a) { }

Are there any technical explanation for this limitation? 

Thanks, Rizo.

--
BF6F0265: FB27 BB4C 8F03 4980 C311 0968 E66B 9831 BF6F 0265


Re: D-Cocoa Port

2012-04-18 Thread Rizo Isrof

On Friday, 13 April 2012 at 14:28:05 UTC, Jacob Carlborg wrote:

On 2012-04-13 15:34, Rizo Isrof wrote:

Hi,

I am planning to use D for creating native applications on Mac 
OS X. For
that, of course, D must interact with the Cocoa API. I have no 
knowledge
of how this bindings could be done. I've already looked at 
Cocado[1] and
do know the Michel Fortin's D-ObjC bridge[2], and would like 
to be

enlightened about some details:
* What is their (or any other possible) approach of porting 
Cocoa to D?

-- here I essentially ask for technical reading sources
(books/articles/references, etc);


There are three ways (two deepening on how you look at it).

1. Use the Objective-C runtime manually, which is implement 
with regular C functions.


https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html

2. Use a bridge that handles everything nicely. The bridge uses 
the same implementation as in the first way. The bridge also 
performs type conversions automatically and other things to 
ease the development.


http://www.dsource.org/projects/dstep
http://michelf.com/projects/d-objc-bridge/

3. Implement direct support in the language to be compatible 
with Objective-C. This is what Michel Fortin did here:


http://michelf.com/projects/d-objc/
(Note, this is not a bridge)

He forked DMD and added support for extern(Objective-C) which 
will output code similar to what GCC/Clang would do. This is a 
more direct way to interface with Objective-C and won't add any 
more overhead than using Objective-C directly would. I guess 
this would mean the ABI's are compatible.


* Is it possible to establish an ABI compatibility with ObjC 
directly or
through the C ABI? -- There's a question on _stackoverflow_[3] 
where the
answers describe what could be achieved with Objective-C's 
Runtime

Reference[4];


Both are possible, see above.

* Is it feasible to make this kind of stuff work nicely and 
get the
level of performance and stability like, e.g., with Qt 
framework on Mac

OS X?


I think so if you use Michel's fork of DMD.

I have no experience at all in this field so forgive me any 
technical

faults. Any help would be appreciable.

Thanks in advance for your responses.


I think the best way is to use the third one mentioned in the 
list above. Note that this is based on an older version of DMD. 
The project is not finished yet and is currently on old. 
Although an alpha version has been released.


The problem with a bridge is the it cause way to much bloat. A 
Hello World application written using a bridge generated a 60MB 
executable.


Using the Objective-C runtime manually is just too verbose and 
tedious. If you are interested in this you can have a look at 
my documentation of how my Objective-c/D bridge works and is 
implemented:


http://www.dsource.org/projects/dstep/wiki/ObjcBridge/BridgeInternals


[1]: http://sourceforge.net/projects/cocodao/
[2]: http://michelf.com/projects/d-objc/


Note, this is not a bridge. This is third one mentioned in the 
list above.


[3]: 
http://stackoverflow.com/questions/5901508/calling-cocoa-apis-from-c

[4]:
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html


- Rizo


Thank you for such a detailed overview of the existing approaches 
- it helped me a lot to understand the theory. As you suggested, 
I will probably use a modified version of the compiler for tests. 
But in order to fully understand the implementation details I 
will try to write my own  extension of D for LDC with 
`extern(Objective-C)` support.


Thanks again for you answer.

- Rizo



Re: GUI library

2012-04-13 Thread Rizo Isrof

On Sunday, 25 March 2012 at 15:59:21 UTC, Jacob Carlborg wrote:

On 2012-03-25 17:22, Kevin Cox wrote:
I would reccomend Qt as well.  You will get native 
cross-platform
widgets with great performance.  I am not sure how far QtD is 
but I know

it once had a lot of development on it.


I don't think Qt is uses the native drawing operations on Mac 
OS X.


Qt does support native drawing operations on Mac OS X since 
4.5.0, when it switched from Carbon to Cocoa as its backend. More 
info here[1] and here[2].


[1]: 
http://labs.qt.nokia.com/2007/06/21/wwdc-qt-carbon-64-bit-and-other-buzzwords/
[2]: 
http://labs.qt.nokia.com/2008/03/03/qtmac-cocoa-port-alpha-released/


 - Rizo


Re: GUI library

2012-04-13 Thread Rizo Isrof

On Sunday, 25 March 2012 at 15:14:04 UTC, Jacob Carlborg wrote:
It would also be possible to use Cocoa, as you do with 
Objective-C, but that wouldn't be very practically. There's 
also a DMD fork that directly supports interfacing with 
Objective-C:


http://michelf.com/projects/d-objc/


Why do you say that the usage of Cocoa through the D-ObjC bridge 
would not be very practical? What are the possible limitations?


 - Rizo



D-Cocoa Port

2012-04-13 Thread Rizo Isrof

Hi,

I am planning to use D for creating native applications on Mac OS 
X. For that, of course, D must interact with the Cocoa API. I 
have no knowledge of how this bindings could be done. I've 
already looked at Cocado[1] and do know the Michel Fortin's 
D-ObjC bridge[2], and would like to be enlightened about some 
details:
 * What is their (or any other possible) approach of porting 
Cocoa to D? -- here I essentially ask for technical reading 
sources (books/articles/references, etc);
 * Is it possible to establish an ABI compatibility with ObjC 
directly or through the C ABI? -- There's a question on 
_stackoverflow_[3] where the answers describe what could be 
achieved with Objective-C's Runtime Reference[4];
 * Is it feasible to make this kind of stuff work nicely and get 
the level of performance and stability like, e.g., with Qt 
framework on Mac OS X?


I have no experience at all in this field so forgive me any 
technical faults. Any help would be appreciable.


Thanks in advance for your responses.

[1]: http://sourceforge.net/projects/cocodao/
[2]: http://michelf.com/projects/d-objc/
[3]: 
http://stackoverflow.com/questions/5901508/calling-cocoa-apis-from-c
[4]: 
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html


 - Rizo