Re: Erroneous "auto can only be used for template function parameters"?

2015-06-19 Thread Yuxuan Shui via Digitalmars-d-learn

On Saturday, 20 June 2015 at 01:50:11 UTC, Yuxuan Shui wrote:

Try to compile this code snippet:

import std.traits;
template a(R) {
auto a(S)(auto ref R i) {
return cast(S)i*2;
}
}
template ReturnTypeEx(alias A, B) {
alias ReturnTypeEx = ReturnType!(A!B);
}
template b(alias R) {
int b(S)(S i) {
alias Ra = ReturnTypeEx!(R, S);
return cast(int)R!S(i);
}
}
void main() {
alias bb = b!(a!ulong);
pragma(msg, ReturnTypeEx!(bb, int));
}

DMD reports:
sadf.d(3): Error: auto can only be used for template function 
parameters
sadf.d(8): Error: template instance sadf.a!ulong.A!int error 
instantiating

sadf.d(12):instantiated from here: ReturnTypeEx!(a, int)
sadf.d(8):instantiated from here: A!int
sadf.d(18):instantiated from here: ReturnTypeEx!(b, int)
sadf.d(18):while evaluating pragma(msg, 
ReturnTypeEx!(b, int))


But a(S)(auto ref R) is indeed a template function, so I don't 
understand.


Another thing I discovered is instantiation like this: (a!T)!S 
will result in "C style cast illegal", which is clearly wrong 
because this is not a cast, (a!T) is not necessarily a type.


Erroneous "auto can only be used for template function parameters"?

2015-06-19 Thread Yuxuan Shui via Digitalmars-d-learn

Try to compile this code snippet:

import std.traits;
template a(R) {
auto a(S)(auto ref R i) {
return cast(S)i*2;
}
}
template ReturnTypeEx(alias A, B) {
alias ReturnTypeEx = ReturnType!(A!B);
}
template b(alias R) {
int b(S)(S i) {
alias Ra = ReturnTypeEx!(R, S);
return cast(int)R!S(i);
}
}
void main() {
alias bb = b!(a!ulong);
pragma(msg, ReturnTypeEx!(bb, int));
}

DMD reports:
sadf.d(3): Error: auto can only be used for template function 
parameters
sadf.d(8): Error: template instance sadf.a!ulong.A!int error 
instantiating

sadf.d(12):instantiated from here: ReturnTypeEx!(a, int)
sadf.d(8):instantiated from here: A!int
sadf.d(18):instantiated from here: ReturnTypeEx!(b, int)
sadf.d(18):while evaluating pragma(msg, ReturnTypeEx!(b, 
int))


But a(S)(auto ref R) is indeed a template function, so I don't 
understand.


Re: OT - civility in a professional environment

2015-06-19 Thread Robert burner Schadek via Digitalmars-d-learn

nice read, thank you


Re: best way to interface D code to Excel

2015-06-19 Thread Jesse Phillips via Digitalmars-d-learn

On Wednesday, 17 June 2015 at 18:35:36 UTC, Laeeth Isharc wrote:

Hi.

I know D has support for COM - not sure of its status.  And 
there was a Microsoft chap who posted here a couple of years 
back - wonderful templated code that made it easy to write this 
kind of thing.  Unfortunately he wasn't able to share it 
publicly.


Laeeth.


I haven't ever done any real work with it, and certainly nothing 
with Excel. But Juno provides similarities for COM to what the 
Microsoft guy demonstrated.


I made some changes so it would compile in dmd 2.070, didn't test 
though so it is still it's own branch.


https://github.com/JesseKPhillips/Juno-Windows-Class-Library/tree/dmd6.070


OT - civility in a professional environment

2015-06-19 Thread Laeeth Isharc via Digitalmars-d-learn

http://www.nytimes.com/2015/06/21/opinion/sunday/is-your-boss-mean.html?_r=0

Off topic, but perhaps of interest.


Laeeth.


Re: Return types of the methods of a struct

2015-06-19 Thread Steven Schveighoffer via Digitalmars-d-learn

On 6/19/15 12:09 PM, Quentin Ladeveze wrote:

On Friday, 19 June 2015 at 14:42:59 UTC, Steven Schveighoffer wrote:

On 6/19/15 10:13 AM, Quentin Ladeveze wrote:

On Friday, 19 June 2015 at 14:04:05 UTC, Daniel Kozák wrote:


On Fri, 19 Jun 2015 13:52:52 +
Quentin Ladeveze via Digitalmars-d-learn
 wrote:


On Friday, 19 June 2015 at 13:38:45 UTC, Steven Schveighoffer wrote:
>
> Does this work for you, or is there a further expectation?
>
> auto asTuple() { return Tuple!(int, "a", ...)(a, b, > >
stringValue);}
>
> -Steve

In fact, I was trying to use traits to create the tuple
automatically and being able to add or remove methods to the
struct without breaking the asTuple method.
I used allMembers for the name of the methods, but I didn't found
anything for their return types or their values.

Thank you.

http://dlang.org/phobos/std_traits.html#ReturnType
http://dlang.org/phobos/std_traits.html#ParameterTypeTuple


These are interesting and can be useful, but allMembers returns strings
and not functions, so I can't apply ReturnType.


It's a *compile time* string. D is able to do some amazing things with
this :)

// assuming 'a' is the first member
mixin("alias aReturnType = ReturnType!(Example." ~
__traits(allMembers, Example)[0] ~ ");");
static assert(is(aReturnType == int));

Using foreach over allMembers, you can construct a perfect return
tuple using introspection and mixin.

-Steve


I would never have thought about mixins, this is amazing ! But thinking
at compile time still is a little difficult for me, and now I don't
understand how you can construct your tuple. I've been trying to create
a string, by iterating on allMembers and concatenating the result of my
functions in a string. But of course, I cannot use this string at
compile time.

Now I know there is a way t do it, but my brain just can't figure it out.

Can you help me ?


The string must stay compile time. This means it must be calculated:

1. in a mixin statement

Example is what I wrote earlier.

2. as an initializer to an immutable, enum, or non-local variable

enum x = "Blah." ~ __traits(allMembers, Blah)[0]; // x is compile-time

3. inside a CTFE function. A CTFE function is just a normal runtime 
function with restrictions (see 
http://dlang.org/function.html#interpretation). But you must *call* it 
from a context like 1 or 2:


string foo(string a, string b) { return a ~ b; } // foo is CTFEable

auto x1 = foo("a", "b"); // x1 is a runtime string, foo is called at runtime
enum x2 = foo("a", "b"); // x2 is a compile-time string, foo is executed 
at compile time (it is not called during execution of your program

mixin("int " ~ x1 ~ ";"); // error, can't use runtime string x1
mixin("int " ~ x2 ~ ";"); // ok, declares int ab;
mixin("int " ~ foo("c", "d") ~ ";"); // ok, declares int ab;

Keep your code all executing at compile time, and you can use your 
strings to write your code for you!


-Steve


Re: Are stack+heap classes possible in D?

2015-06-19 Thread rsw0x via Digitalmars-d-learn

On Friday, 19 June 2015 at 19:10:11 UTC, Shachar Shemesh wrote:

On 14/06/15 04:31, Adam D. Ruppe wrote:

On Sunday, 14 June 2015 at 00:52:20 UTC, FujiBar wrote:
I have read that in D structs are always allocated on the 
stack while

classes are always allocated on the heap.


That's not true; it is a really common misconception.

Putting a struct on the heap is trivial and built into the 
language: `S*

s = new S();`


Well

Yeah. You would get a reference to a struct. The struct will be 
on the heap. In that narrow sense, you are right that it is 
possible.


However, this does not behave like a normal struct. In 
particular, when will the destructor be called? (answer: never, 
not even before the memory is collected).


So, no, I think D experts should avoid telling newbies it is 
okay to just "new struct foo".[1]


Shachar

1 - The counter argument is, of course, that struct destructors 
should not be counted upon to do anything useful anyways, as 
they are far from guaranteed to run even in situations where 
one would expect them to. This just relates to another area 
where D skirts truth in advertising when people say that D 
supports RAII.


the destructor bug has been fixed for a while. for your second 
point, the issue is that D doesn't separate destructors from 
finalizers and it feels like it was designed by someone with 
little knowledge in low level memory management honestly.


Re: Are stack+heap classes possible in D?

2015-06-19 Thread Shachar Shemesh via Digitalmars-d-learn

On 14/06/15 04:31, Adam D. Ruppe wrote:

On Sunday, 14 June 2015 at 00:52:20 UTC, FujiBar wrote:

I have read that in D structs are always allocated on the stack while
classes are always allocated on the heap.


That's not true; it is a really common misconception.

Putting a struct on the heap is trivial and built into the language: `S*
s = new S();`


Well

Yeah. You would get a reference to a struct. The struct will be on the 
heap. In that narrow sense, you are right that it is possible.


However, this does not behave like a normal struct. In particular, when 
will the destructor be called? (answer: never, not even before the 
memory is collected).


So, no, I think D experts should avoid telling newbies it is okay to 
just "new struct foo".[1]


Shachar

1 - The counter argument is, of course, that struct destructors should 
not be counted upon to do anything useful anyways, as they are far from 
guaranteed to run even in situations where one would expect them to. 
This just relates to another area where D skirts truth in advertising 
when people say that D supports RAII.


Re: Return types of the methods of a struct

2015-06-19 Thread Quentin Ladeveze via Digitalmars-d-learn

On Friday, 19 June 2015 at 15:47:09 UTC, ZombineDev wrote:

On Friday, 19 June 2015 at 14:13:46 UTC, Quentin Ladeveze wrote:

[..]
These are interesting and can be useful, but allMembers 
returns strings and not functions, so I can't apply ReturnType.


Here's my solution:
http://dpaste.dzfl.pl/c69de3c16d75


Thank you very much, this solution is interesting too.


Re: Return types of the methods of a struct

2015-06-19 Thread Quentin Ladeveze via Digitalmars-d-learn

On Friday, 19 June 2015 at 15:36:54 UTC, Justin Whear wrote:

On Fri, 19 Jun 2015 13:27:13 +, Quentin Ladeveze wrote:


Is there any way to have a asTuple method in this struct that 
would returns something like :


Tuple!(int, "a", float, "b", string, "c")

and that will contain the values of the methods of the struct ?

Thanks.


You'll want to work your way through this example carefully as 
it's
basically template-based functional programming, but I think 
does what

you want:
 http://dpaste.dzfl.pl/b048ea3adb93


This is interesting, thank you very much ! I will try to figure 
out how it works now


Re: Return types of the methods of a struct

2015-06-19 Thread Quentin Ladeveze via Digitalmars-d-learn
On Friday, 19 June 2015 at 14:42:59 UTC, Steven Schveighoffer 
wrote:

On 6/19/15 10:13 AM, Quentin Ladeveze wrote:

On Friday, 19 June 2015 at 14:04:05 UTC, Daniel Kozák wrote:


On Fri, 19 Jun 2015 13:52:52 +
Quentin Ladeveze via Digitalmars-d-learn
 wrote:

On Friday, 19 June 2015 at 13:38:45 UTC, Steven 
Schveighoffer wrote:

>
> Does this work for you, or is there a further expectation?
>
> auto asTuple() { return Tuple!(int, "a", ...)(a, b, > 
> stringValue);}

>
> -Steve

In fact, I was trying to use traits to create the tuple
automatically and being able to add or remove methods to the
struct without breaking the asTuple method.
I used allMembers for the name of the methods, but I didn't 
found

anything for their return types or their values.

Thank you.

http://dlang.org/phobos/std_traits.html#ReturnType
http://dlang.org/phobos/std_traits.html#ParameterTypeTuple


These are interesting and can be useful, but allMembers 
returns strings

and not functions, so I can't apply ReturnType.


It's a *compile time* string. D is able to do some amazing 
things with this :)


// assuming 'a' is the first member
mixin("alias aReturnType = ReturnType!(Example." ~ 
__traits(allMembers, Example)[0] ~ ");");

static assert(is(aReturnType == int));

Using foreach over allMembers, you can construct a perfect 
return tuple using introspection and mixin.


-Steve


I would never have thought about mixins, this is amazing ! But 
thinking at compile time still is a little difficult for me, and 
now I don't understand how you can construct your tuple. I've 
been trying to create a string, by iterating on allMembers and 
concatenating the result of my functions in a string. But of 
course, I cannot use this string at compile time.


Now I know there is a way t do it, but my brain just can't figure 
it out.


Can you help me ?


Re: Return types of the methods of a struct

2015-06-19 Thread ZombineDev via Digitalmars-d-learn

On Friday, 19 June 2015 at 14:13:46 UTC, Quentin Ladeveze wrote:

[..]
These are interesting and can be useful, but allMembers returns 
strings and not functions, so I can't apply ReturnType.


Here's my solution:
http://dpaste.dzfl.pl/c69de3c16d75


Re: Return types of the methods of a struct

2015-06-19 Thread Justin Whear via Digitalmars-d-learn
On Fri, 19 Jun 2015 13:27:13 +, Quentin Ladeveze wrote:
> 
> Is there any way to have a asTuple method in this struct that would
> returns something like :
> 
> Tuple!(int, "a", float, "b", string, "c")
> 
> and that will contain the values of the methods of the struct ?
> 
> Thanks.

You'll want to work your way through this example carefully as it's 
basically template-based functional programming, but I think does what 
you want:
 http://dpaste.dzfl.pl/b048ea3adb93


Re: Return types of the methods of a struct

2015-06-19 Thread Steven Schveighoffer via Digitalmars-d-learn

On 6/19/15 10:13 AM, Quentin Ladeveze wrote:

On Friday, 19 June 2015 at 14:04:05 UTC, Daniel Kozák wrote:


On Fri, 19 Jun 2015 13:52:52 +
Quentin Ladeveze via Digitalmars-d-learn
 wrote:


On Friday, 19 June 2015 at 13:38:45 UTC, Steven Schveighoffer wrote:
>
> Does this work for you, or is there a further expectation?
>
> auto asTuple() { return Tuple!(int, "a", ...)(a, b, > stringValue);}
>
> -Steve

In fact, I was trying to use traits to create the tuple
automatically and being able to add or remove methods to the
struct without breaking the asTuple method.
I used allMembers for the name of the methods, but I didn't found
anything for their return types or their values.

Thank you.

http://dlang.org/phobos/std_traits.html#ReturnType
http://dlang.org/phobos/std_traits.html#ParameterTypeTuple


These are interesting and can be useful, but allMembers returns strings
and not functions, so I can't apply ReturnType.


It's a *compile time* string. D is able to do some amazing things with 
this :)


// assuming 'a' is the first member
mixin("alias aReturnType = ReturnType!(Example." ~ __traits(allMembers, 
Example)[0] ~ ");");

static assert(is(aReturnType == int));

Using foreach over allMembers, you can construct a perfect return tuple 
using introspection and mixin.


-Steve


Re: Return types of the methods of a struct

2015-06-19 Thread Steven Schveighoffer via Digitalmars-d-learn

On 6/19/15 10:01 AM, Baz wrote:

On Friday, 19 June 2015 at 13:52:54 UTC, Quentin Ladeveze wrote:

On Friday, 19 June 2015 at 13:38:45 UTC, Steven Schveighoffer wrote:


Does this work for you, or is there a further expectation?

auto asTuple() { return Tuple!(int, "a", ...)(a, b, stringValue);}

-Steve


In fact, I was trying to use traits to create the tuple automatically
and being able to add or remove methods to the struct without breaking
the asTuple method.
I used allMembers for the name of the methods, but I didn't found
anything for their return types or their values.

Thank you.


when the return type is defined inside the function it's called a
'Voldemort type',
see http://www.drdobbs.com/cpp/voldemort-types-in-d/232901591?pgno=2


Actually, this isn't a voldemort type, because the type can be named 
outside the function.


-Steve


Re: Return types of the methods of a struct

2015-06-19 Thread Quentin Ladeveze via Digitalmars-d-learn

On Friday, 19 June 2015 at 14:04:05 UTC, Daniel Kozák wrote:


On Fri, 19 Jun 2015 13:52:52 +
Quentin Ladeveze via Digitalmars-d-learn
 wrote:

On Friday, 19 June 2015 at 13:38:45 UTC, Steven Schveighoffer 
wrote:

>
> Does this work for you, or is there a further expectation?
>
> auto asTuple() { return Tuple!(int, "a", ...)(a, b, 
> stringValue);}

>
> -Steve

In fact, I was trying to use traits to create the tuple
automatically and being able to add or remove methods to the
struct without breaking the asTuple method.
I used allMembers for the name of the methods, but I didn't 
found

anything for their return types or their values.

Thank you.
http://dlang.org/phobos/std_traits.html#ReturnType 
http://dlang.org/phobos/std_traits.html#ParameterTypeTuple


These are interesting and can be useful, but allMembers returns 
strings and not functions, so I can't apply ReturnType.





Re: Return types of the methods of a struct

2015-06-19 Thread Baz via Digitalmars-d-learn

On Friday, 19 June 2015 at 13:52:54 UTC, Quentin Ladeveze wrote:
On Friday, 19 June 2015 at 13:38:45 UTC, Steven Schveighoffer 
wrote:


Does this work for you, or is there a further expectation?

auto asTuple() { return Tuple!(int, "a", ...)(a, b, 
stringValue);}


-Steve


In fact, I was trying to use traits to create the tuple 
automatically and being able to add or remove methods to the 
struct without breaking the asTuple method.
I used allMembers for the name of the methods, but I didn't 
found anything for their return types or their values.


Thank you.


when the return type is defined inside the function it's called a 
'Voldemort type',
see 
http://www.drdobbs.com/cpp/voldemort-types-in-d/232901591?pgno=2


Re: Return types of the methods of a struct

2015-06-19 Thread Daniel Kozák via Digitalmars-d-learn

On Fri, 19 Jun 2015 13:52:52 +
Quentin Ladeveze via Digitalmars-d-learn
 wrote:

> On Friday, 19 June 2015 at 13:38:45 UTC, Steven Schveighoffer 
> wrote:
> >
> > Does this work for you, or is there a further expectation?
> >
> > auto asTuple() { return Tuple!(int, "a", ...)(a, b, 
> > stringValue);}
> >
> > -Steve
> 
> In fact, I was trying to use traits to create the tuple 
> automatically and being able to add or remove methods to the 
> struct without breaking the asTuple method.
> I used allMembers for the name of the methods, but I didn't found 
> anything for their return types or their values.
> 
> Thank you.
http://dlang.org/phobos/std_traits.html#ReturnType
http://dlang.org/phobos/std_traits.html#ParameterTypeTuple


Re: Return types of the methods of a struct

2015-06-19 Thread Quentin Ladeveze via Digitalmars-d-learn
On Friday, 19 June 2015 at 13:38:45 UTC, Steven Schveighoffer 
wrote:


Does this work for you, or is there a further expectation?

auto asTuple() { return Tuple!(int, "a", ...)(a, b, 
stringValue);}


-Steve


In fact, I was trying to use traits to create the tuple 
automatically and being able to add or remove methods to the 
struct without breaking the asTuple method.
I used allMembers for the name of the methods, but I didn't found 
anything for their return types or their values.


Thank you.


Re: Return types of the methods of a struct

2015-06-19 Thread Baz via Digitalmars-d-learn

On Friday, 19 June 2015 at 13:40:01 UTC, Baz wrote:

On Friday, 19 June 2015 at 13:27:15 UTC, Quentin Ladeveze wrote:
On Friday, 19 June 2015 at 13:26:03 UTC, Steven Schveighoffer 
wrote:

[...]


Thank you :)

Here is th corrected version :

Hi,

  I have a struct with some methods int it, let's say

```
struct Example{
   int a(){
  return someValue;
   }

   float b(){
  return someOtherValue;
   }

   string stringValue(){
  return c;
   }
}

Is there any way to have a asTuple method in this struct that 
would returns something like :


Tuple!(int, "a", float, "b", string, "c")

and that will contain the values of the methods of the struct ?

Thanks.


in the declaration set the return type to 'auto'.
Use 'tuple' instead of 'Tuple'.


Ah, damn, haven't see Steven Schveighoffer answer while i was 
writing. cross post. same thing.


Re: Return types of the methods of a struct

2015-06-19 Thread Steven Schveighoffer via Digitalmars-d-learn

On 6/19/15 9:27 AM, Quentin Ladeveze wrote:

On Friday, 19 June 2015 at 13:26:03 UTC, Steven Schveighoffer wrote:

On 6/19/15 9:13 AM, Quentin Ladeveze wrote:

On Friday, 19 June 2015 at 13:12:08 UTC, Quentin Ladeveze wrote:

Hi,

  I have a struct with some methods int it, let's say

```
struct Example{
   int intValue(){


Hum. How can I delete a post ?


You can't. The forum is backed by a newsgroup, just post the full
corrected version :)

-Steve


Thank you :)

Here is th corrected version :

Hi,

   I have a struct with some methods int it, let's say

```
struct Example{
int a(){
  return someValue;
}

float b(){
   return someOtherValue;
}

string stringValue(){
   return c;
}
}

Is there any way to have a asTuple method in this struct that would
returns something like :

Tuple!(int, "a", float, "b", string, "c")

and that will contain the values of the methods of the struct ?


Does this work for you, or is there a further expectation?

auto asTuple() { return Tuple!(int, "a", ...)(a, b, stringValue);}

-Steve


Re: Return types of the methods of a struct

2015-06-19 Thread Baz via Digitalmars-d-learn

On Friday, 19 June 2015 at 13:27:15 UTC, Quentin Ladeveze wrote:
On Friday, 19 June 2015 at 13:26:03 UTC, Steven Schveighoffer 
wrote:

On 6/19/15 9:13 AM, Quentin Ladeveze wrote:

[...]


You can't. The forum is backed by a newsgroup, just post the 
full corrected version :)


-Steve


Thank you :)

Here is th corrected version :

Hi,

  I have a struct with some methods int it, let's say

```
struct Example{
   int a(){
  return someValue;
   }

   float b(){
  return someOtherValue;
   }

   string stringValue(){
  return c;
   }
}

Is there any way to have a asTuple method in this struct that 
would returns something like :


Tuple!(int, "a", float, "b", string, "c")

and that will contain the values of the methods of the struct ?

Thanks.


in the declaration set the return type to 'auto'.
Use 'tuple' instead of 'Tuple'.



Re: Return types of the methods of a struct

2015-06-19 Thread Quentin Ladeveze via Digitalmars-d-learn
On Friday, 19 June 2015 at 13:26:03 UTC, Steven Schveighoffer 
wrote:

On 6/19/15 9:13 AM, Quentin Ladeveze wrote:
On Friday, 19 June 2015 at 13:12:08 UTC, Quentin Ladeveze 
wrote:

Hi,

  I have a struct with some methods int it, let's say

```
struct Example{
   int intValue(){


Hum. How can I delete a post ?


You can't. The forum is backed by a newsgroup, just post the 
full corrected version :)


-Steve


Thank you :)

Here is th corrected version :

Hi,

  I have a struct with some methods int it, let's say

```
struct Example{
   int a(){
  return someValue;
   }

   float b(){
  return someOtherValue;
   }

   string stringValue(){
  return c;
   }
}

Is there any way to have a asTuple method in this struct that 
would returns something like :


Tuple!(int, "a", float, "b", string, "c")

and that will contain the values of the methods of the struct ?

Thanks.


Re: Return types of the methods of a struct

2015-06-19 Thread Steven Schveighoffer via Digitalmars-d-learn

On 6/19/15 9:13 AM, Quentin Ladeveze wrote:

On Friday, 19 June 2015 at 13:12:08 UTC, Quentin Ladeveze wrote:

Hi,

  I have a struct with some methods int it, let's say

```
struct Example{
   int intValue(){


Hum. How can I delete a post ?


You can't. The forum is backed by a newsgroup, just post the full 
corrected version :)


-Steve


Return types of the methods of a struct

2015-06-19 Thread Quentin Ladeveze via Digitalmars-d-learn

Hi,

  I have a struct with some methods int it, let's say

```
struct Example{
   int intValue(){



Re: Return types of the methods of a struct

2015-06-19 Thread Quentin Ladeveze via Digitalmars-d-learn

On Friday, 19 June 2015 at 13:12:08 UTC, Quentin Ladeveze wrote:

Hi,

  I have a struct with some methods int it, let's say

```
struct Example{
   int intValue(){


Hum. How can I delete a post ?


Re: best way to interface D code to Excel

2015-06-19 Thread Kagamin via Digitalmars-d-learn

On Thursday, 18 June 2015 at 11:36:50 UTC, Arjan wrote:
See the 'COM in plain C' articles by Jeff Glatt which 
demonstrate how to do it using C. This might give you the 
information needed to do it using D.

http://www.codeproject.com/Articles/Jeff-Glatt#articles.


It's a little misleading though. It starts with complaining that 
existing examples hide details and then uses all sorts of macros 
which have the same issue.

HRESULT PASCAL DllGetClassObject

Hehe, this one doesn't use pascal convention of course :)