[personal profile] tangaroa

Consider that a class in c++ or java defines both an implementation and an interface.

Consider the similarities in these three examples:

// Example 1 
interface IFoo {
 // interface
 doStuff();

 // implementation not defined
}
// Example 2
class Foo {

 // implementation
 int x;
 string y;

 //interface
 doStuff(){...}
}
// Example 3
// implementation 
struct foo {
 int x;
 string y;
}

void foo_doStuff(); // interface

An ordinary compiler might be expected to convert lower-level code to a low-level implementation immediately upon reading it. The programmer has defined exactly how the code is to be implemented, and there is no apparent need for higher level considerations.

A hypothetical high-level compiler might first convert as much low level code as possible into a higher-level intermediary language.

  • class Foo is automatically built from struct foo and is automatically populated by the foo_() functions that operate on a struct foo.
  • interface IFoo is automatically built from the internal representation of class Foo
  • This high level representation is saved to an object file and can be accessed by any programming language that can load libraries.

Additional thoughts:

  • An autodoc tool can produce documentation from the resulting high-level objects, especially if the high level object includes comments or links back to the original source code.
  • An IPC mechanism can send the object definition to the receiving side if the receiving side does not have the structure defined.
  • The compiler can detect classes that are binary-compatible with one another and allow them to be casted without harm.

Also, it should be possible for a sufficiently smart compiler to recognize that some for-loops are examples of an iteration. These can be interpreted upwards to a high-level description of an iteration like foreach x in myArray{...} for which the developer has provided a low-level implementation for (i=0; i<length; i++){...}

I cannot think of any benefit to doing this, but it could potentially be done.

From:
Anonymous( )Anonymous This account has disabled anonymous posting.
OpenID( )OpenID You can comment on this post while signed in with an account from many other sites, once you have confirmed your email address. Sign in using OpenID.
User
Account name:
Password:
If you don't have an account you can create one now.
Subject:
HTML doesn't work in the subject.

Message:

 
Notice: This account is set to log the IP addresses of everyone who comments.
Links will be displayed as unclickable URLs to help prevent spam.
Page generated Jun. 28th, 2017 12:18 am
Powered by Dreamwidth Studios