← Back to team overview

ooc-dev team mailing list archive

Generics

 

Hello,

First of all I want to congratulate you for this unbelievable project.
It's the best thing could happens to the old C pal, a breath of fresh
air.

I have started with the guide examples and found that Int type is not
recognized correctly:

printType: func <T> (param: T) {
  if(T == Int) printf("It's an Int! and its value is %d\n", param as
Int)
  else if(T == Char) printf("It's a char! and its value is '%c'\n",
param as Char)
}
printType('c')
// It's a char! and its value is 'c'
printType(42)
// nothing

and

Container: class <T> {
  content: T
  init: func (=content)
  get: func -> T { content }
  set: func (=content)
}

cont1 := Container<Int> new(42)
number := cont1 get()
"number is an %s, and its value is %d\n" printf(number class name,
number)
// number is an SSizeT, and its value is 42

cont2 := Container<String> new("Hi, world!")
message := cont2 get()
"message is a %s, and its value is %s\n" printf(message class name,
message)
// message is a String, and its value is Hi, world!

I'm using 2011-01-31 linux64 Alpaca version on Ubuntu64 10.10

Thank you,
Dan
-- 
This message was sent from Launchpad by
Dan Parnete (https://launchpad.net/~dan-parnete)
using the "Contact this team" link on the ooc development team team page
(https://launchpad.net/~ooc-dev).
For more information see
https://help.launchpad.net/YourAccount/ContactingPeople



Follow ups