Forums

Just a couple of questions

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

Just a couple of questions

Postby rmb_8178 » Sun Apr 13, 2008 11:48 am

Hey,

Just have a couple of quick easy questions. Before I begin, I would like to congratulate the author of this language for releasing it under MIT. That is a great move for everyone, including the author.

First,
Why was nil chosen instead of null or None? It's not a big deal but I was wondering the decision process behind it.

Second,
Now that Cobra is MIT licensed, have you talked with the Mono team about including in their distributions? Would help with exposure to Cobra.

Lastly,
Is the compiler able to include an option for embedding icons in the program, like a -w32icon option in C# to display an icon in the program rather than a generic one?

Thanks in advance.
rmb_8178
 
Posts: 2

Re: Just a couple of questions

Postby Charles » Sun Apr 13, 2008 3:03 pm

rmb_8178 wrote:Hey,

Just have a couple of quick easy questions. Before I begin, I would like to congratulate the author of this language for releasing it under MIT. That is a great move for everyone, including the author.

Yeah I really like the MIT/X license for its simplicity, openness and ease of adoption.

rmb_8178 wrote:First,
Why was nil chosen instead of null or None? It's not a big deal but I was wondering the decision process behind it.

The first choice was to keep it all lower case for ease of typing. Syntax highlighting is sufficient to make such words stand out, if desired.

So then choices are nil, null, nothing, none and (Eiffel actually uses this:) void. "nil" won due to my background in Smalltalk and Objective-C combined with "nil" being the shortest and, therefore, sweetest. LISP is another language that uses "nil", but those were the primary reasons.

rmb_8178 wrote:Second,
Now that Cobra is MIT licensed, have you talked with the Mono team about including in their distributions? Would help with exposure to Cobra.

An interesting idea. I hadn't thought about that.

rmb_8178 wrote:Lastly,
Is the compiler able to include an option for embedding icons in the program, like a -w32icon option in C# to display an icon in the program rather than a generic one?

Not directly, but Cobra uses the C# compiler as its backend and let's you pass additional options to it via -sharp-args:. See "cobra -h". However you embed icons in C#, you should be able to do the same thing in Cobra. But if you get stuck, let us know.

-Chuck
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Just a couple of questions

Postby rmb_8178 » Sun Apr 13, 2008 4:50 pm

An interesting idea. I hadn't thought about that.

It would make more sense to include it in Mono now since I believe they just released their C# compiler under MIT as well, if I am not mistaken.

Not directly, but Cobra uses the C# compiler as its backend and let's you pass additional options to it via -sharp-args:. See "cobra -h". However you embed icons in C#, you should be able to do the same thing in Cobra. But if you get stuck, let us know.


I know it's not a big thing but users tend not to trust windows programs that have the generic blank Window. So at least having the ability to pass options to the csharp such as w32icon is an advantage. Unless I missed it somewhere, it should be posted somewhere.

This is great. I'm coming from a VB.NET/Python background who is trying to find common ground for my projects at work. I was going to go the Boo route but for programs made for other people, the w32icon is a bit of an issue (boo doesn't have that option). Looks like Cobra will be my answer. :D

Time to start hitting the docs...
rmb_8178
 
Posts: 2

Re: Just a couple of questions

Postby hopscc » Mon Apr 14, 2008 12:38 am

To get an icon displaying in a windows explorer display you specify it as a compile time switch ( for csc thats -win32icon) so for cobra
you do
Code: Select all
cobra  ... -sharp-args:'-win32icon:iconname.ico'  ...


Unfortunately thats not all :cry:
To get it displayed on the application window decoration ( and on the taskbar+task manager) you have to set an application icon in/on
the application

Programmatically (modding the sample winforms.cobra)
Code: Select all
"""
Winforms with file icon (shows in explorer) and
Application (Window) icon (shows in window decoration and task manager)

To compile:
cobra -c -t:winexe -r:System.Windows.Forms -r:System.Drawing
                    -sharp-args:'-win32icon:cobra.ico' 380-WinForms.cobra

To run:
winforms

"""

use System.Windows.Forms

class MyForm
   inherits Form

   sig EvtHdlr(sender as Object, args as EventArgs)



   def init
      ch as System.EventHandler  = ref .handleClick
      listen .click, ch
      #      listen .click, ref .handleClick
      
      # set the window title
      .text='WinForm in Cobra'
       # set the application (window) icon
      ic = System.Drawing.Icon('cobra.ico')
      .icon = ic
      
   def handleClick(sender as Object, args as EventArgs)
      trace args
      trace args.toString
      MessageBox.show('You clicked me! sender=[sender]', 'Click Msg')

class Program

   def main is shared
      Application.run(MyForm())



Theres probably even more arcane windows ways to do it as well...
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand


Return to Discussion

Who is online

Users browsing this forum: No registered users and 32 guests