john skaller | 22 May 02:07
Picon

automagical record coercions (record subtyping)

At present if you have a function accepting a record with
the set of fields F, you can call it with a record with
the set of fields G, provided F is subset of G, and,
you *explicitly* coerce G to F:

typedef F = (a:int);
typedef G = (a:int, b:int);
fun f(x:F)=>x.a;
var g = (a=1, b=2);
println$ f( g :>> F);

If you leave off the coercion, you will get this:

Client Error binding expression (f g)
CLIENT ERROR
[lookup_name_with_sig] Can't find f of struct  {a:(int);b:(int);}
In /Users/johnskaller/felix/./ft.flx: line 5, cols 9 to 10
4: var g = (a=1, b=2);
5: println$ f( g);
           **
6:

There's an argument to provide "some kind of subtyping" here:
a G "is an F" (it just has extra fields). The coercion we use has
a common generic name in algebra: "the forgetful functor",
which is a structure preserving map that simply "forgets" some
of its domains structure.

If we could do automagical coercions, you could write "generic"
functions and just call them with any record which extended
(Continue reading)

john skaller | 19 May 09:32
Picon

Re: [felix] Re: Objects in Felix


On 19/05/2012, at 4:44 PM, john skaller wrote:
> 
> At the moment you have to do this:
> 
> typedef ab = (a:int, bint);
> p (z :>> ab);
> 
> i.e. you have to explicitly coerce the record to have the exact fields the
> function requires.

Ah, I should add some comments on "polymorphism" here, meaning
"like Python or Java or C++ virtual functions".

When you do a record coercion it just forgets some fields.
So lets have a look:

interface Base { p: 1 -> 0; } // aka a procedure
interface Derived extends Base {  q: 1 -> 0; }

object B implements Base { 
  omethod proc p() { println$ "Base"; }
}

object D implements Derived {
  omethod p() { println$ "Derived"; }
  omethod q() { println$ "Something"; }
}

var aD = D();
(Continue reading)

john skaller | 17 May 19:38
Picon

Objects in Felix

Felix has been able to do OO for some time, it just isn't sugared.
Here's an example:

//////////////////
// An OO experiment

fun X (var x:int, var y:int) = {
  proc setx(a:int) { x = a; } 
  proc sety(a:int) { x = a; } 
  fun getx() => x;
  fun gety () => y;
  fun sum () => x + y;
  return (setx=setx, sety=sety, getx=getx, sum=sum);
}

var a = X(2,3);
println$ a.getx();
a.setx(22);
println$ a.getx(), a.sum();

var b = a :>> (sum:1->int);

proc f(v:(sum:1->int)) 
{
  match v with
  | (sum= ?pp)=> println$ pp();
  endmatch;
}

f b;
(Continue reading)

john skaller | 17 May 14:48
Picon

install layout

Im still struggling with the install layout.

This makes sense:

felix/share/felix-version/lib/std/*.flx ... etc etc

Each version has a new standard library, tool sources, etc.
This would also cover C++ sources.

Now, the platform dependent stuff is in two parts:

(a) configuration data: *.fpc files, specs for calling C++,
C++ config headers.

(b) compiled binaries: executables, static libs, shared libs

There will be a standard one of these: host, an abstract name
for the current desktop config. Sharable between users.

Other configs could be installed for cross compiling.

Each user currently has $HOME/felix with personal data.
Presently this is just cache data PLUS if the user is a felix
developer, initialisation data for the host config.

In principle, the config data depends on the platform
not on the Felix version. It may change with compiler
upgrades (independently of the Felix version).

So one problem here is whether to version the config data.
(Continue reading)

john skaller | 16 May 03:23
Picon

xml2

How much does the webserver (mikes) and wiki
depend on xml2? 

It's another dependency ..

--
john skaller
skaller@...
http://felix-lang.org

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
john skaller | 15 May 14:21
Picon

Re: [felix] Win 32 build


On 15/05/2012, at 10:11 PM, john skaller wrote:

> c:\documents and
settings\fletch\.felix\cache\text\c\project\github\felix\build\release\test\regress\rt\typeclass_show-01.hpp(108)
: error C2146: syntax error : missing ';' before identifier '_a3804t_73201'
> 
> 
> That's this:
> 
> //PRIMITIVE 3803 INSTANCE 73161: wchar
> typedef int32_t _a3804t_73162;
> 
> Not sure why this should or shouldn't work .. can't see a #include <stdint.h>
> anywhere. So why's it work on OSX .. hnmmm.

We need a policy decision on this. Options:

1. Always include stddef.h and stdint.h 
   (OR cstddef, cstdint ?)

2. Include them conditionally with requirements as usual

(2) is the normal thing for most headers, however some things
are so fundamental we could make a special case.

--
john skaller
skaller@...
http://felix-lang.org
(Continue reading)

john skaller | 15 May 00:10
Picon

reading unit

The following never works and can't be made to work:

var ch = ischannel[unit] ();
var u = read ch;

The reason is: you cannot use the unit value u, so the read is
optimised away. Even

	C_hack::ignore(u);

fails with a diagnostic, because Felix tries to optimise away all units,
and there's a diagnostic in the code generator to report when the
front end failed to do this. The only way to do it is to use
a supervisor call, and it isn't clear even that will work.

--
john skaller
skaller@...
http://felix-lang.org

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
john skaller | 12 May 16:50
Picon

Re: [felix] strange failure


On 13/05/2012, at 12:24 AM, john skaller wrote:
> 
> Anyhow, Felix shouldn't terminate with the writer still on the
> fibre stack (the reader put it there when it read the channel).

Oh.. interesting. Very interesting!!

At present the mainline runs a full scale fibre scheduler.
When you're inside a function, you cannot do a service
request, because a service request is an exchange of control.

If you call a heaped procedures inside a function, it is run by
a mini-scheduler. This mini-scheduler handles subroutine
calling and return, but not channel communication.

But it could! Instead of the mini-scheduler, we could
call the full scheduler. Now, suppose we write to a channel.
The reader is hanging on the channel and gets rescheduled
*on the functions instance of the scheduler*. This should be cool,
even if that procedure previously suspended off the top level
scheduler -- not the wording "off" the top level scheduler.

There's no reason i can think of why it matters where fibre
is executed *provided* it doesn't execute concurrently with
another fibre with which it shares memory (since fibres
do not do any locking or whatever to access memory).

This is actually quite cute, provided I can get my head around
the termination (when the function nested fibres all terminate,
(Continue reading)

john skaller | 10 May 13:10
Picon

catch variable name

So here's the new code:

////
proc mythrow[T] : T  = "throw $1;";
const fred: int = "fred";

try 
  var x = 1;
  mythrow 20;
  x = 10;
catch fred : int =>
  x = 2;
  println$ "Exception " + str fred;
endtry

println$ x;
////

The reason you still have to type the variable name is ...
I don't know how else to do it at the moment.

An obvious implementation is to convert the catch code into a procedure:

proc x73735 (fred:int) { 
  x = 2;
  print$ ..
}

and then:

(Continue reading)

john skaller | 10 May 12:35
Picon

Install tree

I am thinking of changing the install tree to this

	/usr/local/lib/felix/host/felix-latest/....

[replace / with \ on windows]

or perhaps 

felix-latest/host/...

not sure whether to put the target or the version first.
Might have to change the cache address in a similar way.

The idea is that you can say:

flx --target=platform ....

where the default platform is host. The host platform is configured
to edit, compile, and run on your desktop machine (as detected by
the build system).

The platform name would be arbitrary, although it may pay to copy
the idea gcc uses assuming gcc is halfway reasonable about 
cross compilation. I think that's:

	i686-apple-darwin10-gcc-4.2.1

on my box:

	processor-vendor-os-product-version
(Continue reading)

john skaller | 10 May 06:08
Picon

semantics

I'm still struggling to lock down Felix semantics.

As stuff like try/catch shows, certain code has to be stackless,
and other code doesn't.

It's hard to know what's what due to the optimiser.
Current "inline" makes a difference: non-flat code can be
flattened by inlining. You can only do supervisor calls from
flat code (zero stack). If you make C blocks like
try { .. } .catch { .. }  (and sometimes while () { .. } or for () { .. } etc)
you're introducing a stack which prevents returning to the 
supervisor, as well as jumping into the block (you can jump
into a while or for provided there are no variable initialisations
missed)

I need to carefully sort out what's what, and provide annotations
for enforcement. Eg

	stack proc f (..) ...

ensures the proc f is on the stack or inlined not the heap, 

	heap proc f () .. 

ensures inlining or on the heap or something :)

--
john skaller
skaller@...
http://felix-lang.org
(Continue reading)


Gmane