Why should classname <> monkeyfile name
Monkey Forums/Monkey Beginners/Why should classname <> monkeyfile name
| ||
I have an samplefile with the Name sample.monkeyStrict Class sample Function test() End End In my Main File (main.monkey) Strict Import mojo Import brl Import sample Function Main:Int() Local sample:= New sample() Return 0 End Error : Type 'sample' not found If i named it sampleFile.monkey it works |
| ||
http://www.monkey-x.com/docs/html/Programming_Language%20reference.html#modules Seems correct/ Maybe there is a sample function or something like that in the mojo or brl modules. |
| ||
Class names should be PascalCase for standardization purposes. As for a class name not being the same (case match) as the file name, it's because of how the generator works. In your example, "sample" cannot both be a file name identifier and a class name identifier. Hence why it doesn't recognize "sample" as a class. |
| ||
Use Alias directive The Alias directive allows you to assign a local name to a constant, global, function or class declared in another module. This can be used to create 'shortcuts' for clashing identifiers. The syntax for Alias is: Alias Identifier = ModulePath . Identifier Alias directives must appear in the 'import' section of a module, before any code. For example: |
| ||
Okay thank you :) I use lowercase Filenames and uppercase Classes I was just interested in why it may not be the same. Alias I do not want to use, but its also interesting. |