hi everybody, just now I'm follow the book and trying the code..
now, when I write this
var drew : TStudent = TStudent(name: "Tom", age : 12 ) echo("_________________________________________________________") echo (drew of TStudent) echo(drew)
echo("_________________________________________________________") var m = TPerson(name:"jonny",age:12) echo(m.name)
1) first problem: drew can't have id although she is a student, if I set a id I've this var drew : TStudent = TStudent(name: "Tom", age : 12, id:2 ) undeclared field: 'id'
I'm not sure because this looks really weird, I'm not a big fan of OOP (actually I don't like it) but the syntax makes me hope other behaviour, is it something more related to algebraic data types with a weird inheritanc twist??..I can't understand this well
First off, .. code-block:: nimrod preceded by indented paragraphs allows you to insert code snippets with highlighting and all that good stuff!
Second off, are you using the online compiler or a really old compiler? Because that'll do some weird stuff as I've seen. Compiled with the current git branch (built yesterday), the code compiles perfectly fine with the id added. And it runs printing fine, as well.
Now whether or not it's purposively only printing the id for students, I don't quite know. Ask one of the guys who works on the compiler and they'll probably have some answers here.
m.. This isn't a small bug or behavior.. I'm trying the sample code from the official documentation and using the official distributable for Windows, it isn't an early release or a beta release... It is the distributable than you can download in the Nimrod download page
Don't miss understand me, I'm fine dealing with small bugs and I know than I can find several ones previous at the 1.0 release.. But some benefit about this small community is receive better and faster response.. Neither happen in this case
I'm really new using Nimrod and I like it but the lack of community and not receive a good answer makes me rethink if is a good moment for learning it
I would like receive a response telling me that is a bug, or is a bad implementation or use of it for me, than this is not oop and I using this in the wrong way
But I only receive your answer (which I appreciate), saying that maybe I need use a new version (not the available in the page) and this could be a bug
Again, the sample is from the Nimrod documents and for me sounds crazy that this can be a bug... Maybe I will never know.....
The object constructor syntax is a very new feature and some bugs have been fixed since the 0.9.2 release. Perhaps i can be of some more assistance.
Are you having problems getting the newest version of the compiler from github? The instructions are available on the Nimrod repo on Github: https://github.com/Araq/Nimrod#readme
You can also grab a pre-built binary from the Nimrod build farm: http://build.nimrod-code.org. The download link for Windows 32bit (which should also work on 64bit) is available here: http://build.nimrod-code.org/commits/windows-x86/nimrod_b1a7acf7d583.zip.
Hope this helps.