Re: dynamic classes and duck typing

2009-12-21 Thread Ary Borenszweig
Ary Borenszweig wrote: Ary Borenszweig wrote: retard wrote: Tue, 01 Dec 2009 03:16:47 -0800, Walter Bright wrote: Ary Borenszweig wrote: Can you show examples of points 2, 3 and 4? Have opDispatch look up the string in an associative array that returns an associated delegate, then call the

Re: dynamic classes and duck typing

2009-12-03 Thread retard
Thu, 03 Dec 2009 21:35:14 +, BCS wrote: > Hello dsimcha, > >> == Quote from BCS (n...@anon.com)'s article >> >>> Show me ONE thing that can be done using run time meta programming >>> that can't >>> be done as well or better with run time, non-dynamic, non-meta and/or >>> compile >>> time me

Re: dynamic classes and duck typing

2009-12-03 Thread BCS
Hello dsimcha, == Quote from BCS (n...@anon.com)'s article Show me ONE thing that can be done using run time meta programming that can't be done as well or better with run time, non-dynamic, non-meta and/or compile time meta. Unless I'm totally clueless as to what people are talking about when

Re: dynamic classes and duck typing

2009-12-03 Thread Andrei Alexandrescu
dsimcha wrote: == Quote from BCS (n...@anon.com)'s article Show me ONE thing that can be done using run time meta programming that can't be done as well or better with run time, non-dynamic, non-meta and/or compile time meta. Unless I'm totally clueless as to what people are talking about when t

Re: dynamic classes and duck typing

2009-12-03 Thread dsimcha
== Quote from BCS (n...@anon.com)'s article > Show me ONE thing that can be done using run time meta programming that can't > be done as well or better with run time, non-dynamic, non-meta and/or compile > time meta. Unless I'm totally clueless as to what people are talking about > when they say ru

Re: dynamic classes and duck typing

2009-12-03 Thread BCS
Hello Bill, On Wed, Dec 2, 2009 at 3:26 PM, BCS wrote: Hello Sergey, They can, but I question if it's the best way to do it in those languages. Generating code and running it at runtime seems to be pointless. Why have the intermediate step with the code? I have something I want to do, so I u

Re: dynamic classes and duck typing

2009-12-03 Thread BCS
Hello retard, Wed, 02 Dec 2009 21:16:28 +, BCS wrote: Hello Leandro, Again *optimization*. How many times should I say that I agree that D is better than almost every dynamic languages if you need speed? I'm not arguing on that point. What I'm arguing is that (at least for me) the prim

Re: dynamic classes and duck typing

2009-12-03 Thread Adam D. Ruppe
On Wed, Dec 02, 2009 at 11:50:23AM +, retard wrote: > The case I commented on was about fetching values from a db IIRC. What happened to me was the value got returned as the incorrect type, stored, and used later where it threw the exception.. Conceptual code here: === def getPermission(use

Re: dynamic classes and duck typing

2009-12-03 Thread Don
BCS wrote: Hello dsimcha, == Quote from BCS (n...@anon.com)'s article I don't have a link or anything but I remember hearing about a study MS did about finding bugs and what they found is that every reasonably effective tool they looked at found the same amount of bugs (ok, within shouting di

Re: dynamic classes and duck typing

2009-12-02 Thread Walter Bright
Leandro Lucarella wrote: Bubble sort is perfeclty acceptable for, say, a 100 elements array. It always depends on the context, of course, but when doing programs that deals with small data sets and are mostly IO bounded, you *really* can care less about performance and big-O. The thing about

Re: dynamic classes and duck typing

2009-12-02 Thread Andrei Alexandrescu
retard wrote: Wed, 02 Dec 2009 16:00:50 -0800, Andrei Alexandrescu wrote: retard wrote: Wed, 02 Dec 2009 21:16:28 +, BCS wrote: Hello Leandro, Again *optimization*. How many times should I say that I agree that D is better than almost every dynamic languages if you need speed? I'm not

Re: dynamic classes and duck typing

2009-12-02 Thread retard
Wed, 02 Dec 2009 16:00:50 -0800, Andrei Alexandrescu wrote: > retard wrote: >> Wed, 02 Dec 2009 21:16:28 +, BCS wrote: >> >>> Hello Leandro, >> Again *optimization*. How many times should I say that I agree that D is better than almost every dynamic languages if you need speed? >>>

Re: dynamic classes and duck typing

2009-12-02 Thread Andrei Alexandrescu
retard wrote: Wed, 02 Dec 2009 21:16:28 +, BCS wrote: Hello Leandro, Again *optimization*. How many times should I say that I agree that D is better than almost every dynamic languages if you need speed? I'm not arguing on that point. What I'm arguing is that (at least for me) the prima

Re: dynamic classes and duck typing

2009-12-02 Thread Bill Baxter
On Wed, Dec 2, 2009 at 3:26 PM, BCS wrote: > Hello Sergey, > >> BCS wrote: >> >>> I'm not arguing on that point. What I'm arguing is that (at least for >>> me) the primary advantages of metaprogramming are static checks (for >>> non-perf benefits) and performance. Both of these must be done at >>>

Re: dynamic classes and duck typing

2009-12-02 Thread BCS
Hello Sergey, BCS wrote: I'm not arguing on that point. What I'm arguing is that (at least for me) the primary advantages of metaprogramming are static checks (for non-perf benefits) and performance. Both of these must be done at compile time. Runtime metaprogramming just seems pointless *to m

Re: dynamic classes and duck typing

2009-12-02 Thread BCS
Hello Leandro, Don, el 2 de diciembre a las 22:20 me escribiste: They are metaprogramming tasks. Dynamic languages can do some metaprogramming tasks. They can't do those ones. Because they make no sense, I really don't know how to put it. If you need speed, you code in C/C++/D whatever. Its

Re: dynamic classes and duck typing

2009-12-02 Thread Sergey Gromov
BCS wrote: I'm not arguing on that point. What I'm arguing is that (at least for me) the primary advantages of metaprogramming are static checks (for non-perf benefits) and performance. Both of these must be done at compile time. Runtime metaprogramming just seems pointless *to me.* One of im

Re: dynamic classes and duck typing

2009-12-02 Thread Leandro Lucarella
Don, el 2 de diciembre a las 22:20 me escribiste: > Leandro Lucarella wrote: > >BCS, el 2 de diciembre a las 17:37 me escribiste: > >>Hello Leandro, > >> > >> > >>>If you say dynamic languages don't have metaprogramming capabilities, > >>>you just don't have any idea of what a dynamic language re

Re: dynamic classes and duck typing

2009-12-02 Thread Leandro Lucarella
BCS, el 2 de diciembre a las 21:16 me escribiste: > Hello Leandro, > > >BCS, el 2 de diciembre a las 17:37 me escribiste: > > > >>Hello Leandro, > >> > >>>If you say dynamic languages don't have metaprogramming > >>>capabilities, you just don't have any idea of what a dynamic > >>>language reall

Re: dynamic classes and duck typing

2009-12-02 Thread retard
Wed, 02 Dec 2009 21:16:28 +, BCS wrote: > Hello Leandro, >> Again *optimization*. How many times should I say that I agree that D >> is better than almost every dynamic languages if you need speed? > > I'm not arguing on that point. What I'm arguing is that (at least for > me) the primary ad

Re: dynamic classes and duck typing

2009-12-02 Thread Don
Leandro Lucarella wrote: BCS, el 2 de diciembre a las 17:37 me escribiste: Hello Leandro, If you say dynamic languages don't have metaprogramming capabilities, you just don't have any idea of what a dynamic language really is. If you say you can do metaprogramming at runtime you just don't

Re: dynamic classes and duck typing

2009-12-02 Thread BCS
Hello Leandro, BCS, el 2 de diciembre a las 17:37 me escribiste: Hello Leandro, If you say dynamic languages don't have metaprogramming capabilities, you just don't have any idea of what a dynamic language really is. If you say you can do metaprogramming at runtime you just don't have any

Re: dynamic classes and duck typing

2009-12-02 Thread Leandro Lucarella
BCS, el 2 de diciembre a las 17:37 me escribiste: > Hello Leandro, > > > >If you say dynamic languages don't have metaprogramming capabilities, > >you just don't have any idea of what a dynamic language really is. > > > > If you say you can do metaprogramming at runtime you just don't have > an

Re: dynamic classes and duck typing

2009-12-02 Thread Walter Bright
retard wrote: I agree some disciplines are hard to follow. For example ensuring immutability in a inherently mutable language. But TDD is something a bit easier - it's a lot higher level. It's easy to remember that you can't write any code into production code folder unless there is already cod

Re: dynamic classes and duck typing

2009-12-02 Thread BCS
Hello dsimcha, == Quote from BCS (n...@anon.com)'s article I don't have a link or anything but I remember hearing about a study MS did about finding bugs and what they found is that every reasonably effective tool they looked at found the same amount of bugs (ok, within shouting distance, clos

Re: dynamic classes and duck typing

2009-12-02 Thread Steven Schveighoffer
On Wed, 02 Dec 2009 02:22:01 -0500, retard wrote: You don't seem to have any idea what the term 'dynamic' means. From http://en.wikipedia.org/wiki/Dynamic_programming_language I'm sure the first person who suggested C++ templates were a functional language was shown wikipedia (or whatever

Re: dynamic classes and duck typing

2009-12-02 Thread dsimcha
== Quote from BCS (n...@anon.com)'s article > Hello dsimcha, > > My biggest gripe about static verification is that it can't help you > > at all with high-level logic/algorithmic errors, only lower level > > coding errors. Good unit tests (and good asserts), on the other hand, > > are invaluable f

Re: dynamic classes and duck typing

2009-12-02 Thread BCS
Hello Leandro, If you say dynamic languages don't have metaprogramming capabilities, you just don't have any idea of what a dynamic language really is. If you say you can do metaprogramming at runtime you just don't have any idea of what I want to do with metaprogramming. For example: uni

Re: dynamic classes and duck typing

2009-12-02 Thread BCS
Hello Denis, What if you don't know argument names a-priori? Consider a generic Dynamic class that has nothing but a single opDispatch method. you can do whatever logic you want, even (I think) aliasing the function template opDispatch(string s) { static if(WhateverLogicYouNeed!(s))

Re: dynamic classes and duck typing

2009-12-02 Thread BCS
Hello dsimcha, My biggest gripe about static verification is that it can't help you at all with high-level logic/algorithmic errors, only lower level coding errors. Good unit tests (and good asserts), on the other hand, are invaluable for finding and debugging high-level logic and algorithmic e

Re: dynamic classes and duck typing

2009-12-02 Thread Michal Minich
Hello bearophile, But in dynamic code you don't almost never assert that a variable is an int; you assert that 'a' is able to do its work where it's used. So 'a' can often be an int, decimal, a multiprecision long, a GMP multiprecision, or maybe even a float. What you care of it not what a is bu

Re: dynamic classes and duck typing

2009-12-02 Thread bearophile
dsimcha: >because Python's builtin arrays are too slow.< Python lists are not badly implemented, it's the interpreter that's slow (*). Python built-in arrays (lists) are dynamically typed, so they are less efficient but more flexible. NumPy arrays are the opposite. So as usual with data structu

Re: dynamic classes and duck typing

2009-12-02 Thread bearophile
Walter Bright: > But with mechanical checking, you can guarantee certain things. Usually what mechanical checking guarantee is not even vaguely enough, and such guarantee aren't even about the most important parts :-) Unit tests are more important, because they cover things that matter more. Bett

Re: dynamic classes and duck typing

2009-12-02 Thread Don
Bill Baxter wrote: On Tue, Dec 1, 2009 at 11:43 AM, Don wrote: Bill Baxter wrote: On Tue, Dec 1, 2009 at 5:18 AM, Lutger wrote: Ary Borenszweig wrote: The feature isn't very dynamic since the dispatch rules are defined statically. The only thing you can do is rewire the associative I don't

Re: dynamic classes and duck typing

2009-12-02 Thread dsimcha
== Quote from retard (r...@tard.com.invalid)'s article > I thought D was supposed to be a practical language for real world > problems. This 'D is good because everything can and must be written in > D' is beginning to sound like a religion. You're missing the point. Mixing languages always adds

Re: dynamic classes and duck typing

2009-12-02 Thread retard
Wed, 02 Dec 2009 13:12:58 +0100, Lars T. Kyllingstad wrote: > std.conv.to() to the rescue! :) > >import std.conv; >... > >row[] a = sql_engine.execute("select * from foobar;").result; > >int b = to!int(a[0][0]); // Throws if conversions fail >string c = to!string(a[

Re: dynamic classes and duck typing

2009-12-02 Thread Lars T. Kyllingstad
retard wrote: Wed, 02 Dec 2009 03:16:58 -0800, Walter Bright wrote: retard wrote: The thing is, nowadays when all development should follow the principles of clean code (book), agile, and tdd/bdd, this cannot happen. You write tests first, then the production code. They say that writing tests

Re: dynamic classes and duck typing

2009-12-02 Thread retard
Wed, 02 Dec 2009 03:16:58 -0800, Walter Bright wrote: > retard wrote: >> The thing is, nowadays when all development should follow the >> principles of clean code (book), agile, and tdd/bdd, this cannot >> happen. You write tests first, then the production code. They say that >> writing tests and

Re: dynamic classes and duck typing

2009-12-02 Thread Walter Bright
retard wrote: The thing is, nowadays when all development should follow the principles of clean code (book), agile, and tdd/bdd, this cannot happen. You write tests first, then the production code. They say that writing tests and code takes less time than writing only the more or less buggy pro

Re: dynamic classes and duck typing

2009-12-02 Thread Walter Bright
retard wrote: Tue, 01 Dec 2009 14:24:01 -0800, Walter Bright wrote: Unit tests have their limitations as well. Unit tests cannot prove a function is pure, for example. Sure, unit tests can't prove that. Both unit tests and static verification are needed. But it doesn't lead to this conclus

Re: dynamic classes and duck typing

2009-12-02 Thread Denis Koroskin
On Wed, 02 Dec 2009 00:01:41 +0300, Bill Baxter wrote: On Tue, Dec 1, 2009 at 12:38 PM, Steven Schveighoffer wrote: On Tue, 01 Dec 2009 15:06:27 -0500, Pelle Månsson wrote: Steven Schveighoffer wrote: Isn't opBinary almost identical to opDispatch? The only difference I see is that o

Re: dynamic classes and duck typing

2009-12-02 Thread Michal Minich
Hello retard, Tue, 01 Dec 2009 14:24:01 -0800, Walter Bright wrote: dsimcha wrote: My biggest gripe about static verification is that it can't help you at all with high-level logic/algorithmic errors, only lower level coding errors. Good unit tests (and good asserts), on the other hand, are

Re: dynamic classes and duck typing

2009-12-02 Thread Lars T. Kyllingstad
Andrei Alexandrescu wrote: Leandro Lucarella wrote: Walter Bright, el 1 de diciembre a las 13:45 me escribiste: Leandro Lucarella wrote: I develop twice as fast in Python than in D. Of course this is only me, but that's where I think Python is better than D :) If that is not just because you

Re: dynamic classes and duck typing

2009-12-02 Thread Lutger
Andrei Alexandrescu wrote: > > I'm amazed that virtually nobody uses rdmd. I can hardly fathom how I > managed to make-do without it. > > Andrei rdmd is a life saver, I use it all the time.

Re: dynamic classes and duck typing

2009-12-02 Thread Lutger
Leandro Lucarella wrote: > > I guess D can greatly benefit from a compiler that can compile and run > a multiple-files program with one command (AFAIK rdmd only support one > file programs, right?) and an interactive console that can get the ddoc > documentation on the fly. But that's not very re

Re: dynamic classes and duck typing

2009-12-02 Thread Don
retard wrote: Tue, 01 Dec 2009 12:40:21 -0500, Steven Schveighoffer wrote: On Tue, 01 Dec 2009 11:58:43 -0500, Denis Koroskin <2kor...@gmail.com> wrote: On Tue, 01 Dec 2009 19:41:46 +0300, Steven Schveighoffer wrote: On Tue, 01 Dec 2009 11:20:06 -0500, Denis Koroskin <2kor...@gmail.com> wr

Re: dynamic classes and duck typing

2009-12-02 Thread Pelle Månsson
Andrei Alexandrescu wrote: Pelle Månsson wrote: Walter Bright wrote: Leandro Lucarella wrote: I guess D can greatly benefit from a compiler that can compile and run a multiple-files program with one command dmd a b c -run args... Can we have dmd -resolve-deps-and-run main.d I use rdmd wh

Re: dynamic classes and duck typing

2009-12-02 Thread Andrei Alexandrescu
Pelle Månsson wrote: Walter Bright wrote: Leandro Lucarella wrote: I guess D can greatly benefit from a compiler that can compile and run a multiple-files program with one command dmd a b c -run args... Can we have dmd -resolve-deps-and-run main.d I use rdmd when I can, but it doesn't man

Re: dynamic classes and duck typing

2009-12-02 Thread Pelle Månsson
Walter Bright wrote: Leandro Lucarella wrote: I guess D can greatly benefit from a compiler that can compile and run a multiple-files program with one command dmd a b c -run args... Can we have dmd -resolve-deps-and-run main.d I use rdmd when I can, but it doesn't manage to link C-libs in

Re: dynamic classes and duck typing

2009-12-01 Thread Pelle Månsson
Walter Bright wrote: But you can do that with the 'with' statement! The with goes at the use end, not the object declaration end. Or I read the spec wrong. So does the scope guard. I think scope guard solves the same problem as the with-statement, only it does it in a more flexible and arguab

Re: dynamic classes and duck typing

2009-12-01 Thread BLS
On 28/11/2009 00:30, Walter Bright wrote: One thing Java and Python, Ruby, etc., still hold over D is dynamic classes, i.e. classes that are only known at runtime, not compile time. In D, this: s.foo(3); Should opDispatch also enable dynamic property injection ? I just thought that it would b

Re: dynamic classes and duck typing

2009-12-01 Thread Pelle Månsson
retard wrote: Tue, 01 Dec 2009 14:22:10 -0800, Walter Bright wrote: bearophile wrote: Right. But what people care in the end is programs that get the work done. If a mix of Python plus C/C++ libs are good enough and handy enough then they get used. For example I am able to use the PIL Python l

Re: dynamic classes and duck typing

2009-12-01 Thread retard
Tue, 01 Dec 2009 12:40:21 -0500, Steven Schveighoffer wrote: > On Tue, 01 Dec 2009 11:58:43 -0500, Denis Koroskin <2kor...@gmail.com> > wrote: > >> On Tue, 01 Dec 2009 19:41:46 +0300, Steven Schveighoffer >> wrote: >> >>> On Tue, 01 Dec 2009 11:20:06 -0500, Denis Koroskin <2kor...@gmail.com> >>>

Re: dynamic classes and duck typing

2009-12-01 Thread retard
Tue, 01 Dec 2009 14:24:01 -0800, Walter Bright wrote: > dsimcha wrote: >> My biggest gripe about static verification is that it can't help you at >> all with high-level logic/algorithmic errors, only lower level coding >> errors. Good unit tests (and good asserts), on the other hand, are >> inval

Re: dynamic classes and duck typing

2009-12-01 Thread retard
Tue, 01 Dec 2009 16:58:32 -0500, Adam D. Ruppe wrote: > On Tue, Dec 01, 2009 at 09:17:44PM +, retard wrote: >> The lack of type annotations at least removes all typing bugs. > > Quite the contrary, leaving off the type annotation spawns bugs. It spawns new bugs, for sure, but it removes all

Re: dynamic classes and duck typing

2009-12-01 Thread retard
Tue, 01 Dec 2009 14:22:10 -0800, Walter Bright wrote: > bearophile wrote: >> Right. But what people care in the end is programs that get the work >> done. If a mix of Python plus C/C++ libs are good enough and handy >> enough then they get used. For example I am able to use the PIL Python >> lib w

Re: dynamic classes and duck typing

2009-12-01 Thread retard
Tue, 01 Dec 2009 13:15:53 -0800, Walter Bright wrote: > grauzone wrote: >> Walter Bright wrote: >>> dsimcha wrote: In Java, by going overboard on making the core language simple, you end up pushing all the complexity into the APIs. >>> >>> Yup, and that's the underlying problem with "sim

Re: dynamic classes and duck typing

2009-12-01 Thread Andrei Alexandrescu
Bill Baxter wrote: On Tue, Dec 1, 2009 at 5:08 PM, Bill Baxter wrote: On Tue, Dec 1, 2009 at 4:37 PM, Andrei Alexandrescu wrote: Leandro Lucarella wrote: Walter Bright, el 1 de diciembre a las 13:45 me escribiste: Leandro Lucarella wrote: I develop twice as fast in Python than in D. Of co

Re: dynamic classes and duck typing

2009-12-01 Thread Andrei Alexandrescu
Bill Baxter wrote: On Tue, Dec 1, 2009 at 4:37 PM, Andrei Alexandrescu wrote: Leandro Lucarella wrote: Walter Bright, el 1 de diciembre a las 13:45 me escribiste: Leandro Lucarella wrote: I develop twice as fast in Python than in D. Of course this is only me, but that's where I think Python

Re: dynamic classes and duck typing

2009-12-01 Thread Walter Bright
Leandro Lucarella wrote: I think code translation from other languages is not a good reason for adding complexity... I think it is. We wouldn't have DWT otherwise, for example. Inner classes were added specifically in order to speed up the translation process. The code complexity is suppo

Re: dynamic classes and duck typing

2009-12-01 Thread Walter Bright
dsimcha wrote: == Quote from Walter Bright (newshou...@digitalmars.com)'s article D has three: RAII, scope guard, and try-catch-finally. As far as I'm concerned, the only reason t-c-f isn't taken out to the woodshed and shot is to make it easy to translate code from other languages to D. I've

Re: dynamic classes and duck typing

2009-12-01 Thread Steven Schveighoffer
Bill Baxter Wrote: > On Tue, Dec 1, 2009 at 4:22 PM, Steven Schveighoffer > wrote: > > Bill Baxter Wrote: > > > >> Good counterpoints to my argument.  So I give up on that line. > >> > >> Here's another, how do you implement the opBinary_r operators with > >> opDispatch? > > > > Kinda cooky, but

Re: dynamic classes and duck typing

2009-12-01 Thread Leandro Lucarella
Walter Bright, el 1 de diciembre a las 17:31 me escribiste: > Leandro Lucarella wrote: > >It looks like you can (not as easily) according to bearophile example, but > >this is besides the point, you only want to use malloc() for performance > >reasons, and I already said that D is better than Pyth

Re: dynamic classes and duck typing

2009-12-01 Thread dsimcha
== Quote from Walter Bright (newshou...@digitalmars.com)'s article > D has three: RAII, scope guard, and try-catch-finally. As far as I'm > concerned, the only reason t-c-f isn't taken out to the woodshed and > shot is to make it easy to translate code from other languages to D. I've literally nev

Re: dynamic classes and duck typing

2009-12-01 Thread Bill Baxter
On Tue, Dec 1, 2009 at 5:08 PM, Bill Baxter wrote: > On Tue, Dec 1, 2009 at 4:37 PM, Andrei Alexandrescu > wrote: >> Leandro Lucarella wrote: >>> >>> Walter Bright, el  1 de diciembre a las 13:45 me escribiste: Leandro Lucarella wrote: > > I develop twice as fast in Python than

Re: dynamic classes and duck typing

2009-12-01 Thread Walter Bright
Leandro Lucarella wrote: It looks like you can (not as easily) according to bearophile example, but this is besides the point, you only want to use malloc() for performance reasons, and I already said that D is better than Python on that. I mentioned ctypes just for the point of easy C-interopera

Re: dynamic classes and duck typing

2009-12-01 Thread Walter Bright
Leandro Lucarella wrote: I guess D can greatly benefit from a compiler that can compile and run a multiple-files program with one command dmd a b c -run args...

Re: dynamic classes and duck typing

2009-12-01 Thread Walter Bright
bearophile wrote: Walter Bright: Ok, does this work: p = libc.malloc(100); *p = 3; ? Or this: struct S { int a; char b; }; S s; libc.fillInS(&s); The purpose of ctypes is to interface Python with C libs, it's a quite well designed piece of software engineering. This is how you can do what

Re: dynamic classes and duck typing

2009-12-01 Thread Bill Baxter
On Tue, Dec 1, 2009 at 4:37 PM, Andrei Alexandrescu wrote: > Leandro Lucarella wrote: >> >> Walter Bright, el  1 de diciembre a las 13:45 me escribiste: >>> >>> Leandro Lucarella wrote: I develop twice as fast in Python than in D. Of course this is only me, but that's where I think

Re: dynamic classes and duck typing

2009-12-01 Thread Andrei Alexandrescu
Leandro Lucarella wrote: Walter Bright, el 1 de diciembre a las 13:45 me escribiste: Leandro Lucarella wrote: I develop twice as fast in Python than in D. Of course this is only me, but that's where I think Python is better than D :) If that is not just because you know the Python system far

Re: dynamic classes and duck typing

2009-12-01 Thread Bill Baxter
On Tue, Dec 1, 2009 at 4:22 PM, Steven Schveighoffer wrote: > Bill Baxter Wrote: > >> Good counterpoints to my argument.  So I give up on that line. >> >> Here's another, how do you implement the opBinary_r operators with >> opDispatch? > > Kinda cooky, but what about this: > > a + b -> b.opDispa

Re: dynamic classes and duck typing

2009-12-01 Thread Steven Schveighoffer
Bill Baxter Wrote: > Good counterpoints to my argument. So I give up on that line. > > Here's another, how do you implement the opBinary_r operators with opDispatch? Kinda cooky, but what about this: a + b -> b.opDispatch!("r+" )(a) -Steve

Re: dynamic classes and duck typing

2009-12-01 Thread Leandro Lucarella
Walter Bright, el 1 de diciembre a las 13:45 me escribiste: > Leandro Lucarella wrote: > >I develop twice as fast in Python than in D. Of course this is only me, > >but that's where I think Python is better than D :) > > If that is not just because you know the Python system far better > than the

Re: dynamic classes and duck typing

2009-12-01 Thread Leandro Lucarella
Walter Bright, el 1 de diciembre a las 13:43 me escribiste: > Leandro Lucarella wrote: > >5. simple interfacing to C > In case you mean no unnecessary wrappers etc., this has more to > do with the execution model than language features. Most > scripting languages are interpreted, a

Re: dynamic classes and duck typing

2009-12-01 Thread bearophile
Walter Bright: > Ok, does this work: > > p = libc.malloc(100); > *p = 3; > > ? Or this: > > struct S { int a; char b; }; > S s; > libc.fillInS(&s); The purpose of ctypes is to interface Python with C libs, it's a quite well designed piece of software engineering. This

Re: dynamic classes and duck typing

2009-12-01 Thread Bill Baxter
On Tue, Dec 1, 2009 at 3:01 PM, Steven Schveighoffer wrote: >> How about this: given only a catch-all opDispatch which implements >> dynamic dispatch, the compiler cannot statically determine if >> operators are really implemented or not. > > Why does it have to? > proposed implementation: > > com

Re: dynamic classes and duck typing

2009-12-01 Thread Steven Schveighoffer
On Tue, 01 Dec 2009 17:24:30 -0500, Bill Baxter wrote: On Tue, Dec 1, 2009 at 1:10 PM, Steven Schveighoffer wrote: On Tue, 01 Dec 2009 16:01:41 -0500, Bill Baxter wrote: On Tue, Dec 1, 2009 at 12:38 PM, Steven Schveighoffer wrote: On Tue, 01 Dec 2009 15:06:27 -0500, Pelle Månsson wro

Re: dynamic classes and duck typing

2009-12-01 Thread Walter Bright
Andrei Alexandrescu wrote: Parameters to dynDispatch (the user-defined forwarding function), NOT opDispatch. opDispatch can take _anything_. Sorry if I'm repeating what you know already, but I am obsessing over a small misunderstanding could end up hamstringing this very powerful feature. S

Re: dynamic classes and duck typing

2009-12-01 Thread Walter Bright
Adam D. Ruppe wrote: You might say that I should have been more disciplined about [...] That's the usual excuse for poor language design . What I've been trying to do with D is enable more static verification, so that the project team can rely on enforced guarantees rather than discipline, e

Re: dynamic classes and duck typing

2009-12-01 Thread Walter Bright
dsimcha wrote: My biggest gripe about static verification is that it can't help you at all with high-level logic/algorithmic errors, only lower level coding errors. Good unit tests (and good asserts), on the other hand, are invaluable for finding and debugging high-level logic and algorithmic er

Re: dynamic classes and duck typing

2009-12-01 Thread Walter Bright
bearophile wrote: Right. But what people care in the end is programs that get the work done. If a mix of Python plus C/C++ libs are good enough and handy enough then they get used. For example I am able to use the PIL Python lib with Python to load, save and process jpeg images at high-speed with

Re: dynamic classes and duck typing

2009-12-01 Thread Bill Baxter
On Tue, Dec 1, 2009 at 1:10 PM, Steven Schveighoffer wrote: > On Tue, 01 Dec 2009 16:01:41 -0500, Bill Baxter wrote: > >> On Tue, Dec 1, 2009 at 12:38 PM, Steven Schveighoffer >> wrote: >>> >>> On Tue, 01 Dec 2009 15:06:27 -0500, Pelle Månsson >>> >>> wrote: >>> Steven Schveighoffer wrote:

Re: dynamic classes and duck typing

2009-12-01 Thread Andrei Alexandrescu
Adam D. Ruppe wrote: On Tue, Dec 01, 2009 at 09:17:44PM +, retard wrote: The lack of type annotations at least removes all typing bugs. Quite the contrary, leaving off the type annotation spawns bugs. Yah, I was wondering about that! The hypothesis is there, but the conclusion was the n

Re: dynamic classes and duck typing

2009-12-01 Thread bearophile
Walter Bright: > I meant it in the form of the simpler being better hypothesis. I see, I have missed that purpose of the discussion... I am sorry. > The very existence of those shows that Python itself is not powerful enough. Right. But what people care in the end is programs that get the work

Re: dynamic classes and duck typing

2009-12-01 Thread Walter Bright
Don wrote: Bill Baxter wrote: And once again we see Clugston's Law at work. As soon as you figure out how to do one thing in D, a new compiler feature comes along that makes it a one-liner. :-) I love it! Part of that is just that Don is very good at figuring out what needs to be supporte

Re: dynamic classes and duck typing

2009-12-01 Thread Walter Bright
Leandro Lucarella wrote: I develop twice as fast in Python than in D. Of course this is only me, but that's where I think Python is better than D :) If that is not just because you know the Python system far better than the D one, then yes indeed it is a win. I think only not having a compi

Re: dynamic classes and duck typing

2009-12-01 Thread Adam D. Ruppe
On Tue, Dec 01, 2009 at 09:17:44PM +, retard wrote: > The lack of type annotations at least removes all typing bugs. Quite the contrary, leaving off the type annotation spawns bugs. I had to write a web app in Ruby last year, and well remember the little things that slipped past tests, pissin

Re: dynamic classes and duck typing

2009-12-01 Thread Walter Bright
Leandro Lucarella wrote: 5. simple interfacing to C In case you mean no unnecessary wrappers etc., this has more to do with the execution model than language features. Most scripting languages are interpreted, and require some sort of assistance from the runtime system. If the language was compi

Re: dynamic classes and duck typing

2009-12-01 Thread bearophile
dsimcha: > Good unit > tests (and good asserts), on the other hand, are invaluable for finding and > debugging high-level logic and algorithmic errors. Contract programming too can help. For example in a precondition of a binary search function you can test that the items are sorted. If you don't

Re: dynamic classes and duck typing

2009-12-01 Thread Walter Bright
bearophile wrote: I suggest Walter to don't try to say that D2 is "better" than Python, it's a waste of time and it means nothing. I meant it in the form of the simpler being better hypothesis. I am arguing that a simpler language often leads to complex code. CorePy, PyCuda, PyOpenCL, etc. a

Re: dynamic classes and duck typing

2009-12-01 Thread dsimcha
== Quote from retard (r...@tard.com.invalid)'s article > Tue, 01 Dec 2009 10:46:11 -0800, Walter Bright wrote: > > Leandro Lucarella wrote: > >> I really think the *only* *major* advantage of D over Python is speed. > >> That's it. > > > > I probably place a lot more importance on static verificati

Re: dynamic classes and duck typing

2009-12-01 Thread Walter Bright
grauzone wrote: Walter Bright wrote: dsimcha wrote: In Java, by going overboard on making the core language simple, you end up pushing all the complexity into the APIs. Yup, and that's the underlying problem with "simple" languages. Complicated code. I think users of scripting languages wo

Re: dynamic classes and duck typing

2009-12-01 Thread retard
Tue, 01 Dec 2009 17:11:26 -0300, Leandro Lucarella wrote: > And again, judging from experience, I don't know why, but I really have > a very small bug count when using Python. I don't work with huge teams > of crappy programmers (which I think is the scenario that D tries to > cover), that can be

Re: dynamic classes and duck typing

2009-12-01 Thread Walter Bright
Andrei Alexandrescu wrote: Yah, point taken :o). I probably haven't clarified enough that I'm talking about a mere belief. Arguments have been discussed here in the past (e.g. scalability of the language construct with multiple transactions). Time will tell, but one indicating factor is that p

Re: dynamic classes and duck typing

2009-12-01 Thread retard
Tue, 01 Dec 2009 10:46:11 -0800, Walter Bright wrote: > Leandro Lucarella wrote: >> I really think the *only* *major* advantage of D over Python is speed. >> That's it. > > I probably place a lot more importance on static verification rather > than relying on convention and tons of unit tests.

Re: dynamic classes and duck typing

2009-12-01 Thread retard
Tue, 01 Dec 2009 10:39:44 -0800, Andrei Alexandrescu wrote: > retard wrote: >> Tue, 01 Dec 2009 03:16:47 -0800, Walter Bright wrote: >> >>> Ary Borenszweig wrote: Can you show examples of points 2, 3 and 4? >>> Have opDispatch look up the string in an associative array that >>> returns an as

Re: dynamic classes and duck typing

2009-12-01 Thread Steven Schveighoffer
On Tue, 01 Dec 2009 16:01:41 -0500, Bill Baxter wrote: On Tue, Dec 1, 2009 at 12:38 PM, Steven Schveighoffer wrote: On Tue, 01 Dec 2009 15:06:27 -0500, Pelle Månsson wrote: Steven Schveighoffer wrote: Isn't opBinary almost identical to opDispatch? The only difference I see is that o

Re: dynamic classes and duck typing

2009-12-01 Thread Bill Baxter
On Tue, Dec 1, 2009 at 1:01 PM, Bill Baxter wrote: > On Tue, Dec 1, 2009 at 12:38 PM, Steven Schveighoffer > wrote: >> On Tue, 01 Dec 2009 15:06:27 -0500, Pelle Månsson >> wrote: >> >>> Steven Schveighoffer wrote: >>  Isn't opBinary almost identical to opDispatch?  The only difference I >>>

Re: dynamic classes and duck typing

2009-12-01 Thread Bill Baxter
On Tue, Dec 1, 2009 at 12:38 PM, Steven Schveighoffer wrote: > On Tue, 01 Dec 2009 15:06:27 -0500, Pelle Månsson > wrote: > >> Steven Schveighoffer wrote: > >>>  Isn't opBinary almost identical to opDispatch?  The only difference I >>> see is that opBinary works with operators as the 'symbol' and

Re: dynamic classes and duck typing

2009-12-01 Thread Steven Schveighoffer
On Tue, 01 Dec 2009 15:06:27 -0500, Pelle Månsson wrote: Steven Schveighoffer wrote: Isn't opBinary almost identical to opDispatch? The only difference I see is that opBinary works with operators as the 'symbol' and dispatch works with valid symbols. Is it important to distinguish be

  1   2   3   >