Forums

Small idea - class/method placeholders

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Small idea - class/method placeholders

Postby hopscc » Wed Mar 05, 2014 4:47 am

Just noted that building the compiler selfhosting (use it to build itself) generates 142 warnings for
Code: Select all
 warning: Encountered "pass" in a class that already has declared members.


This is due a warning on use of "pass" in a class that already has some box members defined
(CobraParser.cobra .classPass)
as in
class X is partial
pass
where class X is already declared something like

class X
def foo
print 'foo.'

def main is shared
x = X()
x.foo



This use seems to indicate a worthwhile doc mechanism so seems it might be worthwhile to allow this without warning if the class is declared partial which would allow the use of an explicit specification of a partial class as a placeholder for effort to be done later
i.e a placeholder/reminder for new named methods and fields to be implemented in the future
e.g.
class X is partial
pass # must implement the variant foo methods eventually


(ticket:367)

An alternative option would be to introduce a 'todo' or 'tobeimplemented' keyword that could be placed in such classes (same as pass) to note such use as temp placeholders with perhaps some trailing text ..
extend this for methods as well??

e.g.
class X is partial
todo : Implement variant foo methods and supporting fields
# 'todo keyword indicates class is placeholder, no code generated for it
# : precedes trailing text comment/doc following (aesthetic only)

class Y
def baz
pass
# empty method baz

def bar
todo
# placeholder for method bar - no code generated

def bar1
todo : needs to adjust for froz on goober
# placeholder for method bar1 - no code generated, additional trailing note


??
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Small idea - class/method placeholders

Postby Charles » Sat Mar 08, 2014 9:39 pm

Like other "partial" problems, such as being stuck with the "use" directives of the first "partial" type declaration, this is likely to be the outcome of Cobra implementing the partial types incorrectly. I have some progress on this, but have not sealed the deal due to some collateral damage around the treatment of method overloads.

Regarding the "todo" idea, I don't follow your idea of no code being generated for "bar1". What happens if bar1 is invoked somewhere? Error, warning, ...?

But most importantly there are many situations where you might be a "to-do" or other comment, and I'm not convinced there's value for adding this as language feature in some places.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Small idea - class/method placeholders

Postby hopscc » Sun Mar 09, 2014 4:52 am

no code generated

For a method/class - no code for the contents ( same as pass is now as described earlier)

Effectively it looks like we are already using a combination of pass and possibly optional comment to do this already..
This is just to hoist that idea to make the use/idea obvious and explicit...

Its also possible/easier to extract classes methods so marked rather than a search on a notation convention in a comment
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Small idea - class/method placeholders

Postby Charles » Sun Mar 09, 2014 11:02 am

For annotating declarations, .NET attributes come to mind.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Small idea - class/method placeholders

Postby hopscc » Tue Mar 11, 2014 4:05 am

Which more clearly communicates items to be implemented ??

class X is partial
todo : Implement variant foo methods and supporting fields

class Y has Humpty('wall')
def baz
pass

def bar has Dumpty('fall')
todo


vs

class X is partial has ToDo('Implement variant foo methods and supporting fields')

class Y has Humpty('wall')
def baz
pass

def bar has ToDo, Dumpty('fall')
pass
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Small idea - class/method placeholders

Postby Charles » Tue Mar 11, 2014 9:35 am

To compare them, I would add use the same formatting. Also, were you really planning that what follows the 'todo' would be bare characters instead of a string?

class X is partial
todo : 'Implement variant foo methods and supporting fields'

class X is partial
has ToDo('Implement variant foo methods and supporting fields')


Also, I know how to use reflection to get the info from the 2nd one if I want it programmatically. It's not clear how one would/could do so with the first.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Small idea - class/method placeholders

Postby hopscc » Wed Mar 12, 2014 2:46 am

String or chars - either works

Why would you want to get Todo info from an executable ?.... Its a coding/Implementation thing.
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Small idea - class/method placeholders

Postby hopscc » Wed Mar 12, 2014 2:52 am

I would add use the same formatting


Even so, spot the additional cruft
What does 'has Todo' mean anyway....
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand


Return to Discussion

Who is online

Users browsing this forum: No registered users and 11 guests