Forums

Cobra.Lang to not reference by default

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

Cobra.Lang to not reference by default

Postby RIGHT_THEN » Tue Jun 28, 2011 9:25 am

hey Charles,

when compiling cobra.lang along with cobra there is usually a error that
cobra.lang has allready been included. then one has to do so many round-abouts
to get it working i.e changing namespaces and even then sometimes it fails.
that is because compiler is referencing the Cobra.Lang by default while
compiling assemblies which are inturn trying to reference other Cobra.Lang
which compiler is not using. it results in clash

i would request you to add a switch to compiler which tells it to use the cobra.lang
which we want it to or not at all. that is it should not reference cobra.lang by default if we dont
want it to. because i think Cobra.lang is required if we use cobra specific features isnt it?

just like c# has option to not reference the default mscorlib and user can actually
supply his own mscorlib.dll "/nostdlib"

or is there such option allready if there is it sure is skipping my eyes.

Thanking_You
RIGHT_THEN
RIGHT_THEN
 
Posts: 99

Re: Cobra.Lang to not reference by default

Postby Charles » Tue Jun 28, 2011 11:15 am

RIGHT_THEN wrote:when compiling cobra.lang along with cobra there is usually a error that
cobra.lang has allready been included. then one has to do so many round-abouts
to get it working i.e changing namespaces and even then sometimes it fails.

Can you give me the exact set-up, command and output for this case, so I can see exactly what is going on?

Thanks.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Cobra.Lang to not reference by default

Postby RIGHT_THEN » Thu Jun 30, 2011 12:11 am

hey Charles

Could you please elaborate what goes on behind the scences when given -ert and -bsl switches.

about bsl this is what i know
------------------------------------
you are renaming Cobra.Lang to Cobra.previous.lang.
and then renaming it back to Cobra.Lang.

about ert this is what i assume
---------------------------------------
that cobra.lang files should be included in the source of the
built assembly, or is it something else?. if so then is there some
variable in which you store the info within that assembly that it is
built with -ert or has cobra.lang files right inside it.

if above notion is true then when i compile c#`ed cobra.exe along with cobra.lang files
included in it. that should do, but still while compiling some .cobra files with resultant cobra.exe.
It complains that cobra.lang namespace or cobra.lang.dll is not found. when i reference cobra.lang
to it , it works. i came to one conclusion that either -ert doesnot take away referencing cobra.lang
or there is info within the -ert`ed assembly that cobra.lang is included inside it which it should use
instead of Cobra.Lang which otherwise it would.


Thanking_You
RIGH_THEN
RIGHT_THEN
 
Posts: 99

Re: Cobra.Lang to not reference by default

Postby Charles » Thu Jun 30, 2011 1:39 pm

-bsl renames Cobra.Lang. so that if it fails (which in the very early days was a real possibility), I can rename the "previous" version in order to restare it. -bsl does not rename the "previous" one back. Don't let this distract you. It's probably not relevant to whatever you are doing.

-ert actually compiles the source code of the std library as part of your program. There is also some special code to mangle the Cobra.Lang namespace so that if you use -ert on two separate libraries/dlls, you will not get a conflict.

Note that building the Cobra compiler with bin/build or bin\build.bat, includes -ert:yes. Those are one line commands, so you could experiment with copying them and excluding -ert:yes, if that helps your situation.

See also "def _embedRunTime" in CobraWorkspace/Phases/BindRunTimeLibraryPhase.cobra.

I'd have to see your exact steps to help you further.

HTH
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Cobra.Lang to not reference by default

Postby RIGHT_THEN » Thu Jun 30, 2011 11:48 pm

hey Charles

help me take out this confusion about -ert before i ask something else
i assume i am confusing its functionality with some thing it is not meant for.

when Cobra.Lang is embedded inside of cobra.exe the whole exe has a
mangled namespace Cobra.Lang_ert_something and that envelops Cobra.lang files also

so what does it signify that the embedded Cobra.lang would be good only for
internal use by the compiler for itself and not for the new assemblies or files it compiles
for them cobra.lang would have to be referenced from outside unless the new cobra files to be
compiled were using the same Cobra.Lang_ert_something namespace. Correct?

Thanking_You
RIGHT_THEN
RIGHT_THEN
 
Posts: 99

Re: Cobra.Lang to not reference by default

Postby Charles » Fri Jul 01, 2011 1:37 am

Well as soon as you use -ert:yes which is "-embed-run-time:", it is the case that the embedded code will not be referenced by anything else.

Also, suppose we didn't mangle the name. Then this fails:
Code: Select all
cobra -t:lib -out:A.dll -ert:yes A.cobra
cobra -t:lib -out:B.dll -ert:yes B.cobra
cobra -ref:A -ref:B Prog.cobra

It fails because A and B collide by having the same namespace containing the same type names. But by mangling the name, the above case works.

In the case of the Cobra compiler, or any other program that doesn't use two libs like this, the mangling is not strictly necessary.

Is there a reason why the name mangling and embedding has your attention?
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Cobra.Lang to not reference by default

Postby RIGHT_THEN » Fri Jul 01, 2011 7:34 am

hey Charles,

Charles wrote:Is there a reason why the name mangling and embedding has your attention?


YES

i am trying to compile cobra source in SD solution. it wont work but C#ed version works.

now to work with c# is fine but problems are two
1) every time you make a minor update i have to re-implement it and it is tedious.
2) reading C#`ed cobra isnt that soothing to eyes as is cobra code itself.


see the difference C# produced
protected System.Collections.Generic.List</*dynamic*/object> _rawCommandLineOptionSpecs = CobraLangInternal.CobraImp.MakeList</*dynamic*/object>(typeof(System.Collections.Generic.List</*dynamic*/object>), CobraLangInternal.CobraImp.MakeDict<System.String,System.String>(typeof(System.Collections.Generic.Dictionary<System.String, System.String>), "name","about", "description","Print the name, copyright, etc. but no usage.", "type","main"),

.cobra written by you
var _rawCommandLineOptionSpecs = [
{
'name': 'about',
'description': 'Print the name, copyright, etc. but no usage.',
'type': 'main',
},
{
'name': 'back-end',
'description': 'Specify the back-end of the compiler, possibly different than the build platform. Used for cross-compilation.',
'type': 'menu',
'choices': ['none', 'clr', 'jvm', 'objc'],
'args': 'none|clr|jvm|objc',
'default': 'none',
},


so i try and investigate.

Thanking_You
RIGHT_THEN
RIGHT_THEN
 
Posts: 99

Re: Cobra.Lang to not reference by default

Postby hopscc » Sat Jul 02, 2011 1:01 am

Hmm
I'm probably missing something here but
Why would anyone ever want/need to embed the runtime in a dll (library) ?
( as opposed to embedding it in an app that uses the dll (exe) )
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Cobra.Lang to not reference by default

Postby Charles » Sat Jul 02, 2011 1:47 am

You would embed the run-time in a DLL if you wanted to release a ".NET library" without requiring that people have Cobra.Lang.dll with it, and the correct version at that.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Cobra.Lang to not reference by default

Postby RIGHT_THEN » Sat Jul 02, 2011 8:10 am

hello Mr. hopscc

wheather or not one includes it. It is more relavent from the aspect of
IDE. who so ever makes it how will he deal when some user opens up
Cobra or Cobra.Lang itself in the editor. and at the back intellisense engine
is trying to produce intellisense for the opened files. it produces errors. complaining of
amibuigty of namespaces because it is not supplied with -ert or -bsl.
sure there might be ways to overcome it but not straight one. atleast not in my mind yet.
therefore i was clearning some of my doubts

Thanking_You
RIGHT_THEN
RIGHT_THEN
 
Posts: 99


Return to Discussion

Who is online

Users browsing this forum: No registered users and 49 guests

cron