Page 1 of 1

Cannot find a method "Highlight" with arg type "NameSpace"

PostPosted: Sat Feb 26, 2011 9:59 pm
by RIGHT_THEN
Gentlemen

After parsing file i get a CobraModule i tried to run
Code: Select all
cm1.WriteHtmlHighlightedFileTo(Environment.CurrentDirectory);
on it . that went fine
untill i added namespace to the code file. Error reported is the subject of this post

""" 
mistakes and corrections are intentionally done to
see how would parser respond.
when we put namespace,
Cannot find a method "Highlight" with arg type "NameSpace"
is given by HtmlSource().
"""
namespace Yamamoto

class Main1
"""
I am a Class

"""
def main is shared
"""
i am a method

"""
a as int = 2 # this is a
b = 3 # this is b
z = 4
b = 4 + z
z = a + b
a = z + b
x is string = 'yellow'
print a, b, c
System.Console.writeLine("hello again")
print 'hello'
print 'x'
System.Console.writeLine("hello again")
print 'hello'
print 'x'

def add( num1 , num2 ) as int is shared
return num1 + num2

am i doing something fundamentally wrong or something needs fixing in cobra
and why are doc strings not allowed for namespaces when they are allowed for classes.

also writeDeepString does not report the doc string of the module and class it does of method
i suggest that module level and class level doc-strings be provisioned into Writedeepstring()

Thanking_You
RIGHT_THEN

Re: Cannot find a method "Highlight" with arg type "NameSpac

PostPosted: Sun Feb 27, 2011 1:01 am
by Charles
-- The highlighter had a bug regarding namespaces. Now fixed. Thanks for the report.

-- Regarding doc strings in namespaces: It's common for namespaces to appear many times. You could easily have 20 classes, each in its own file, with a "namespace" declaration in each one. It's not clear how they should be documented then. If there is more than one doc string do they get appended? Replaced? What order?

-- .writeDeepString is for the purpose of debugging the compiler and it seemed that I never needed the doc string when doing so. I still prefer to leave them out. Do you really need that?

Re: Cannot find a method "Highlight" with arg type "NameSpac

PostPosted: Sun Feb 27, 2011 3:14 am
by RIGHT_THEN
Thanks Charles

For fixing it,

Here are few questions

1) can cobra simply convert the code form itself to C# without checking and using reflection
2) at what stage cobra knows exactly what certain ID stands for. i mean its type because there is
duck typing here. and tokenizer does not show the type of ducks.


as far as how to deal with namespace docstrings since it is for the same namespace no order
is required it can be appended as one finds them
"""
1) filename
comment
2) filename
comment
3) so forth ..
"""

-- .writeDeepString is for the purpose of debugging the compiler and it seemed that I never needed the doc string when doing so. I still prefer to leave them out. Do you really need that?


i mentioned it thinking that it could be a bug or unintentionally leftout feature. i can get them
through tokens so no i would not press you for that. let them be as they were.

Thanking_you
RIGHT_THEN

Re: Cannot find a method "Highlight" with arg type "NameSpac

PostPosted: Sun Feb 27, 2011 9:56 am
by Charles
-- The C# code generator assumes that the previous phases of the compiler have executed and passed without error. It would certainly fail if that were not the case.

-- Regarding when the compiler knows what an id stands for:

--- For interface level stuff such as the return type of a method, or the base class of a given class, that would be after "bind interface".

--- For the code inside of methods and properties, that would be after "bind implementation".

--- But that is only for static types. You mentioned duck typing, which I call "dynamic". In that case, only the run-time knows for sure in the general case. Although you could try to do code analysis to determine such things without running the program.

-- As a reminder, for a local var like this:
i = 0

The type is inferred to be static, not dynamic. The local var "i" will always be an "int". Cobra gets much of its speed by favoring static typing like this.

-- Regarding namespace doc strings, you may want to add a ticket. Click "Wiki" which takes you to "Trac" and add a ticket, if you like.

Re: Cannot find a method "Highlight" with arg type "NameSpac

PostPosted: Tue Apr 03, 2012 2:48 am
by hopscc
Patch and tests for allowing docstr on namespaces on ticket:277

Re: Cannot find a method "Highlight" with arg type "NameSpac

PostPosted: Mon Apr 23, 2012 6:21 pm
by Charles
Applied. Thanks.