New project, "Code to Code"

Marc Lanctot lanctot-yfeSBMgouQgsA/PxXw9srA at public.gmane.org
Fri Dec 19 20:17:26 UTC 2008


Madison Kelly wrote:
> Inline reply (sorry, but several good points I'd like to address).

Is inline reply against this list's etiquette or something? You've 
apologized twice. It's second-nature for me to do this. Is isn't 
frowned-upon in general, is it?

> Marc Lanctot wrote:
>> Maybe it's easiest to illustrate with an example. I have lots of 
>> experience with language X and Y, but now because I work for company C 
>> I have to use language Z. (bummer!)
>>
>> So, I coding along happily (or unhappily, as it were) in language Z 
>> and I find myself not knowing how to pass variables by reference.
>>
>> Step 1: I invoke Code-to-Code. First thing I do is lookup "passing 
>> variables by reference in function calls". I find it, I'm happy. I get 
>> sent to a page (this concept's profile) called "Passing variables by 
>> reference to functions". I also see a list of source/target languages.
>>
>> Step 2: I notice my target (Z) is there, let's say Z = C++.
>>
>> Step 3: I choose my source (X) is there, let's say A = Java.
>>
>> Step 4: I click "GO!" and bam, up pops up an example side-by-side. On 
>> the left we have:
> 
> I think this could be done by creating a page, named for the function in 
> question. In there then could be a list of links to articles with that 
> function, sorted by 'X to Y'.
> 
> This should allow Mediawiki's built in search engine to provide you with 
> the information you're looking for.
> 
> Already people are creating a structure to the articles I hadn't thought 
> of. I had planned to create 'X to Y' as a single, complete article. 
> Instead it is evolving as 'X to Y/function|concept|etc' and the 'X to Y' 
> article becomes a list of links. This may be very useful as it would 
> allow for what you are talking about.
> 
> If I am getting this right, then this page should be inline with what 
> you are thinking?
> 
> http://www.codetocode.net/index.php/Python/Arrays

Well, yes kind of. The search feature seems to work well now because it 
isn't full of a lot of data yet. I wonder how slow it would be if it was 
full.

What I'm suggesting is a separate page index of topics (right now these 
topics are on the individual Foo to Bar pages) that is like a meta-index 
for all of the Foo to Bar pages.

No need to worry about this right away, though.

>> void function(int i, ObjectType o)
>> {
>>   // i is passed by value, therefore changes are local
>>   i += 4;
>>
>>   // o is passed by reference.. changes inside persist
>>   o.somefunction();
>>   o.somepublicfield = somevalue;
>> }
>>
>> On the right:
>>
>> void function(int i, int & j, int * k, my_type * ptr, my_type & ref)
>> {
>>   // i is passed by value, changes are local
>>   i += 4;
>>
>>   // j is passed by reference, changes persist
>>   j += 4;
>>
>>   // k's address is passed by value, but you can use it to change
>>   // the value of the variable it is pointing to in memory
>>   // changes persist if you do this
>>   (*k) = 4;
>>
>>   // but not if you do this. address value in k is local
>>   k = 0x08fe82a6;
>>
>>   // changes value of somemember in object pointed to by ptr
>>   o->somemember = somevalue;
>>
>>   // same deal except via a reference
>>   ref.x = 4;
>> }
>>
>> On the bottom:
>>
>> Note1: in Java, all object types are passed by reference whereas all 
>> primitive data types are passed by value.
>>
>> Note2: In C++, all primitive data types are passed by value unless you 
>> use a reference or pointer. There are two way to pass something "by 
>> reference": using a pointer or using a reference. Bla bla bla...
> 
> Another excellent example that could be a seed article for 'Java to 
> C++'! Could I ask you to add it, if you have the time? As I mentioned 
> earlier in this thread, I am more than happy to do it myself, but when 
> possible I'd like to keep attributions intact in the wiki. :)

Yep, and I added a bunch to the Java -> C++ page (mostly string 
manipulation stuff) and I could add even more because I've had to deal 
with these crossings in the past 2 years, but I've put up enough for one 
day :)

I have to say.. I'd much rather sign in once and not have to do the 
CAPTCHA thing every time I edit. And given recent e-vandalism, maybe 
having "contributors" attached to an email address isn't such a bad idea.

Marc
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list