[Grace-core] Blog fodder
Kim Bruce
kim at cs.pomona.edu
Sun May 1 15:14:41 PDT 2011
Somehow I didn't get a chance to look at this page earlier. I tentatively agree with most of the comments on parameterization. A few points:
1. class declarations as first class values. While I also had them as first class values in my book, I'd like to discuss this in the context of my concerns from a week plus ago about object definitions being generative. It comes down to whether object and class definitions should be declarations or regular expressions.
2. I'm a bit surprised to see you write self.type in example 3. While part of me would love to include a mytype style type in the language, it has some consequences for typing. We should discuss this. [Let me know if I am misunderstanding that notation.]
3. The more I think about automagically having class names overloaded with type names (e.g., Complex in your examples), the more nervous I get about it. I'd rather see us require the type definition to be given before the class definition and then use that name in the class definition.
E.g.
type Complex{
method real-> Number
method imag -> Number
method + other:self.type -> self.type
method - other:self.type -> self.type
method abs -> Number
method conj -> self.type
}
const ComplexCartesian := class { re:Number , im:Number ->
const real:Number := re
const imag:Number := im
method + other:self.type -> self.type {
ComplexCartesian.new(real + other.real , imag + other.imag) }
method - other:self.type -> self.type {
ComplexCartesian.new(real - other.real , imag - other.imag) }
method abs -> Number {
(real.squared + imag.squared).sqrt } }
method conj -> self.type {
real - imag.i }
const myComplex: Complex := ComplexCartesian.new(9,3)
[Of course I notice that you used self.type instead of Complex here, but I'd put Complex in its place if we are not going to use that construct.]
Kim
On Apr 27, 2011, at 8:38 AM, Andrew P. Black wrote:
> I wrote this page before I left Cambridge
>
> https://projects.cecs.pdx.edu:8443/~black/NewOOL/index.cgi/wiki/DeclaringThingsWithParameters
>
> There are no comments there. I think that, as it is written, it would make an excellent blog post.
>
> Andrew
>
> _______________________________________________
> Grace-core mailing list
> Grace-core at cecs.pdx.edu
> https://mailhost.cecs.pdx.edu/mailman/listinfo/grace-core
More information about the Grace-core
mailing list