Skip to content

Equivalent super keyword? #19

@bergel

Description

@bergel

👋 I really like your package. Thanks for having written it.
I am left with a question, though: how would you write a super call?
Here is a non-working example:

using Classes

@class Point begin
	x
	y
end

@class mutable ColoredPoint <: Point begin
	color
end

function my_print(p::Point) 
	println("Point { x=$(p.x), y=$(p.y) }")
end

function my_print(p::ColoredPoint) 
	println("ColoredPoint { x=$(p.x), y=$(p.y), color=$(p.color) }")
end

call_my_print(p) = my_print(p)

my_value(p::Point) = 1
my_value(p::ColoredPoint) = 1 + my_value(convert(Point, p))

This last definition is ill-defined; convert(Point, p) will ultimately fail. Have you thought about a way to define super call?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions