Is it possible to delete a blog from the "I read these blogs" list?
MMD distances
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What can I do?
• What to Read?
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Talxy Chat
• Horoscope
• Online
 
Зарегистрируйся!

QAIX > Perl web-programming > MMD distances 9 May 2008 11:29:47

  Recent blog posts: 
  They have birthday today: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Moderators:

MMD distances

John M. Dlugosz 9 May 2008 11:29:47
 TSa Thomas.Sandlass-at-­barco.com |Perl 6| wrote:
Coming back to how C++ handles static overloading. How is
the sort order of (int *), (int &), (int), (const int *),
(const int &), (const int), (int * const) and (const int * const)?
I'm too lazy to look up the details, sorry.

Without looking anything up in the standard,
int and int& are indistinguishable.
int* is a different type from int, and won't be confused.
const vs const int don't matter to the caller.

- const int& is preferred over int/int&.
- const int* is preferred over int*.

--John


OptionsAdd comment
TSa 8 May 2008 17:45:35 permanent link ]
 HaloO,

John M. Dlugosz wrote:
- const int& is preferred over int/int&.
- const int* is preferred over int*.

You mean when in each case both versions are
defined as overloads only the preferred ones
are ever called? C++ is the other way around.
For an int* argument the int* version is preferred
if both are available. For a const int* the int*
is not applicable, thus not choosen.

Now I understand your motivation to mangle the
traits into the (dynamic) dispatch rules. But
note that I would not call the C++ compile time
choice dispatch. I think the standard doesn't either.
It's called overload resolution. Perl 6 can't do
that at compile time unless *all* targets are
available as rw and readonly variants.


Regards, TSa.
--

"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12 -- Srinivasa Ramanujan
Add comment
John M. Dlugosz 9 May 2008 00:07:55 permanent link ]
 TSa Thomas.Sandlass-at-­barco.com |Perl 6| wrote:
It's called overload resolution. Perl 6 can't do
that at compile time unless *all* targets are
available as rw and readonly variants.


I don't follow that statement. Can you give an example?
Add comment
TSa 9 May 2008 11:29:47 permanent link ]
 HaloO,

John M. Dlugosz wrote:
TSa Thomas.Sandlass-at-­barco.com |Perl 6| wrote:
It's called overload resolution. Perl 6 can't do
that at compile time unless *all* targets are
available as rw and readonly variants.
I don't follow that statement. Can you give an example?

multi sub foo (Int $i) {...}
multi sub foo (Int $i is rw) {...}
multi sub foo (Num $n) {...}
multi sub foo (Num $n is rw) {...}

# OK so far

multi sub foo (Str $s is rw) {...} # not OK

sub bar ($x)
{
$x = 3; # error, $x is readonly
foo($x); # error, could hit rw Str
}

I must admit though, that my statement was a bit lax.
All targets readonly is fine. But the first rw
requires the insertion of rw targets for all
other variants. Perhaps you can get away with
less than all if you can prove that they'll never
be in the candidate set together with an rw. Note
that such a prove might be falsified subsequently
by introducing an Any sub like bar above.


Regards, TSa.
--

"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12 -- Srinivasa Ramanujan
Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или УК РФ.


QAIX > Perl web-programming > MMD distances 9 May 2008 11:29:47

see also:
SQLDriverConnect hangs when DB…
Unicode conversion issue
missing Pg.pm in Postgres v7.3.1
see also:
full table...
How many joins is too many joins....
index is not used
see also:
Warning: thr_alarm queue is full errors…
Re: FW: Problem starting a session
converting Oracle to postgres

  Copyright © 2001—2008 QAIX
Idea: Miсhael Monashev
You can find the help and FAQ in the Admin's blog.
Write us at:
If you would like to report an abuse of our service, such as a spam message, please .