type inference on global methods

5 views
Skip to first unread message

sfsf

unread,
Mar 6, 2008, 5:07:10 AM3/6/08
to Nemerle Forum
hallo,
i have a problem with type inference on global methods. nemerle 0.9.3.
is this supported
in the snapshots or the svn trunk??? sorry i can not test this at the
moment. On SuSE 10.3 i have Mono 1.2.6 and i can not compile nemerle
snapshot. i think i need the new mono 1.9.
Where can i find the history of nemerle ???

Operations.n:14:46:14:49: error: type inference on global methods is
not yet supported
Operations.n:14:17:14:49: error: type inference not allowed here

class Operations {
public static Swap (n1 : out int, n2 : out int) {
def tmp = n1;
n1 = n2;
n2 = tmp;
}
}

Dmitry Ivankov

unread,
Mar 6, 2008, 5:28:03 AM3/6/08
to nemer...@googlegroups.com
On 3/6/08, sfsf <s...@granit.de> wrote:

hallo,
i have a problem with type inference on global methods. nemerle 0.9.3.
is this supported
in the snapshots or the svn trunk???

No, it's not supported anywhere..
 

sorry i can not test this at the
moment. On SuSE 10.3 i have Mono 1.2.6 and i can not compile nemerle
snapshot. i think i need the new mono 1.9.

If the message is smth like "Field not found" then it's a bug in 1.2.6, afair 1.2.5 worked and it seems like 1.9 should work too.

Where can i find the history of nemerle ???

What exactly do you mean by history? :) 

Operations.n:14:46:14:49: error: type inference on global methods is
not yet supported
Operations.n:14:17:14:49: error: type inference not allowed here

class Operations {
  public static Swap (n1 : out int, n2 : out int) {
    def tmp = n1;
    n1 = n2;
    n2 = tmp;
  }
}

Just specify void return type ;)



Ķaмȋļ ๏ Şκaļşκȋ

unread,
Mar 6, 2008, 6:32:46 AM3/6/08
to nemer...@googlegroups.com
On Thu, Mar 6, 2008 at 11:28 AM, Dmitry Ivankov <divan...@gmail.com> wrote:
>
>
>
> On 3/6/08, sfsf <s...@granit.de> wrote:
> >
> > hallo,
> > i have a problem with type inference on global methods. nemerle 0.9.3.
> > is this supported
> > in the snapshots or the svn trunk???
>
> No, it's not supported anywhere..
>
>
>
> > sorry i can not test this at the
> > moment. On SuSE 10.3 i have Mono 1.2.6 and i can not compile nemerle
> > snapshot. i think i need the new mono 1.9.
>
> If the message is smth like "Field not found" then it's a bug in 1.2.6,
> afair 1.2.5 worked and it seems like 1.9 should work too.
>

AFAIK the bug in mono is still alive.

> > Where can i find the history of nemerle ???
>
> What exactly do you mean by history? :)
>
> > Operations.n:14:46:14:49: error: type inference on global methods is
> > not yet supported
> > Operations.n:14:17:14:49: error: type inference not allowed here
> >
> > class Operations {
> > public static Swap (n1 : out int, n2 : out int) {
> > def tmp = n1;
> > n1 = n2;
> > n2 = tmp;
> > }
> > }
>
> Just specify void return type ;)
> >
> >
>
>
>
> >
>

--
Kamil Skalski
http://nazgul.omega.pl

sfsf

unread,
Mar 6, 2008, 6:35:29 AM3/6/08
to Nemerle Forum
hallo,
sorry my mistake .. this is what i want. i misunderstood the error
message. sorry !!!!!!!!! -- greate it works

class Operations {
public static Swap (n1 : out int, n2 : out int) : void {
def tmp = n1;
n1 = n2;
n2 = tmp;
}
}

history ... i mean the changelog or so - to see what you have changed
per version/snapshot.

but an other a few questions. i hope this is not no match work.

we want to exchange our own scripting language (like pascal, not oop
pascal) with an other scripting language. the scripting language is
embedded in our CAD system running on linux.

features:
- Preprocessor with ifdef ifndef else usw.
- we can include functions from a other source file
- datatypes int,real,char,string, static array of int,real,char,string
- execute a script within a other script
- functional programming language
- interface to the cad functions (cad in programmed in C)
- debugger - i can stop the execution of the script to look for work i
have made with in
script and later i go back to debug further
- show the values of my variables
- set breakpoints
- trace over or in a function
- change value of variable
- terminate the script
- evalute expressions with variable and/or functions from
my current context
- automaticly call function on the begin / end or exit of a script
without explicit call it
- one main per script
- function paramter with call by value and call by reference
- global variable
- begin - end - blocks (like pascal)
- function return values
- if else
- switch with int/string or expressions values
- for, while, repeat/until
- local variable
- evaluate expression within the current context -- a = berstr("b
+c*(func(a)/3.4)");
- append strings with "+"
- uppercase of string with +str;
- lowercase of string with -str;
- global initialize of array with one value
- every variable is automatic initialized with zero or a empty string
- string compare with ==
- decrement/increment values with ii++ / ii--;
- const and mutable variable
- forever loops -- while (true)... or for(;;) ...
- break and continue like in C - breaks/continue over one level in
nested loops/ifs
- ifdef with expressions where executed during compilation
- execute bytecode it is a interpreter - only the syntax tree is
written/read to/from file
- functions from include files which is not needed for execution the
script will be deleted
- binary operators
- trigometric functions
- usw.
- shell execution


what we have not :
- no gui in script -- only over a extern program
- dynamic array
- no structs
- no classes
- no public,private,...
- no goto or labels
- no unicode strings only char strings (like in old c)

wish list
- embedded a new script language in our cad
- support more languages not only german and english
- interface to a gui library like qt -- gtk is available
- all what we have not

i hope, i have nothing forget in this list.

please can anyone comment this list ??? can nemerle support this
features or ????








On 6 Mrz., 11:28, "Dmitry Ivankov" <divanor...@gmail.com> wrote:
> On 3/6/08, sfsf <s...@granit.de> wrote:
>
>
>
> > hallo,
> > i have a problem with type inference on global methods. nemerle 0.9.3.
> > is this supported
> > in the snapshots or the svn trunk???
>
> No, it's not supported anywhere..
>
> sorry i can not test this at the
>
> > moment. On SuSE 10.3 i have Mono 1.2.6 and i can not compile nemerle
> > snapshot. i think i need the new mono 1.9.
>
> If the message is smth like "Field not found" then it's a bug in 1.2.6
> , afair 1.2.5 worked and it seems like 1.9 should work too.

VladD2

unread,
Mar 6, 2008, 9:12:46 AM3/6/08
to nemer...@googlegroups.com
2008/3/6, sfsf <s...@granit.de>:

> please can anyone comment this list ??? can nemerle support this
> features or ????

1. Nemerle can be used as automation language, but it is not scripting
language.
We can implement feature like "evaluate expression within the current


context -- a = berstr("b

+c*(func(a)/3.4)")", but it will be work slowly.
2. Nemerle is not Pascal. And convert syntax will be very difficulty (I think).

I think all other item you get or can be implement if you choice Nemerle.

PS

What is "usw"?

sfsf

unread,
Mar 7, 2008, 1:33:53 AM3/7/08
to Nemerle Forum
hallo,
usw. -- in german "und so weiter" / in english -- on so far (i think)

1. what is the difference between automation language and scripting
language ??
what is slow -- milliseconds, seconds, minutes or ???

2. Yes, Nemerle is Pascal and we have much to rewrite of our code. but
have we any
alternative or know you ???? c# is nearest to "our" pascal i think.
or you think we
have to code our own nemerle (with other syntax,...).

VladD2

unread,
Mar 7, 2008, 2:41:45 AM3/7/08
to nemer...@googlegroups.com
> 1. what is the difference between automation language and scripting
> language ??

A scripting language is interpreter, but automation language can be
compiled before execution (as also interpreted).

> what is slow -- milliseconds, seconds, minutes or ???

In first run about second (one or two) in second milliseconds. Point
is that you should compile code before execute it. In first time you
need initialize compiler, in second time you should compile code into
MSIL and JIT it. If you cache dynamic assembly (which introduce in
compilation process) second time execution can be match faster in
comparison with interpreter.

You can also combine Nemerle compiler with expression evaluator like
contains in Nemerlish.

> 2. Yes, Nemerle is Pascal and we have much to rewrite of our code. but
> have we any
> alternative or know you ???? c# is nearest to "our" pascal i think.
> or you think we
> have to code our own nemerle (with other syntax,...).

What you mean under Pascal (or under Nemerle is Pasca)?

sfsf

unread,
Mar 7, 2008, 4:00:13 AM3/7/08
to Nemerle Forum
hallo,
1. first execution seconds ??? ... for example "c=a+b" or "c=a
+b*func()" all
of this variables and functions in current context -- i think like
eval() function.

2. it is better to write our own cli compiler/interpreter or should we
use nemerle and
rewrite our code??? what is better ???

sfsf

unread,
Mar 7, 2008, 5:49:27 AM3/7/08
to Nemerle Forum
hallo,
i have forget to tell you a fundamental in our script language.
- first index in array is 1 not 0
- first index in string is 1 not 0 --
str = "test";
pos = str.indexOf("t"); // pos is 1 not 0

Valéry

unread,
Mar 7, 2008, 7:59:47 AM3/7/08
to Nemerle Forum
On 7 mar, 10:00, sfsf <s...@granit.de> wrote:
> it is better to write our own cli compiler/interpreter or should we
> use nemerle and
>    rewrite our code??? what is better ???

If you use Nemerle :
- you immediatly get many features listed in your previous post,
notably a mature functional language, but not all of them.
- Nemerle has a somewhat C#ish synbtax, but you can add most of the
desired syntax features (if then else, begin end, etc.) with macros
(see http://nemerle.org/Macros_tutorial)
- some features you cannot easily get : +str (use str.ToUpper()),
automatic initialization of variables (I don't remember if Nemerle
does it), full scripting (you'll have to wrap your script in a class
with 3 lines of class definition at the top of the file, no big deal)

sfsf

unread,
Mar 7, 2008, 8:25:52 AM3/7/08
to Nemerle Forum
hallo,
have you read my last post about arrays and string ?????? i think this
is a problem.
i can sail around this problem by write my own classes for all types
or or known you
an easier way ????

i have test qt4 csharp binding
compile and install the two packages
qt4-smoke-1.0.0.tar.bz2
qt4-qyoto-1.0.0.tar.bz2

write a little code
using Qyoto;

class Hello
{
static Main (argv : array [string]) : int
{
def app = QApplication(argv);
def button1 = QPushButton("Hello World!");
button1.Resize(100,30);
button1.Show();
return : {
return (QApplication.Exec());
}
}
}

compile
ncc example.n -r:qt-dotnet.dll


and run
mono out.exe

... it runs ... very great .. i love it


but why we must write

return : {
return(...);
}

the same in break continue. can you tell me an easier way or no
way ???



On 7 Mrz., 13:59, Valéry <valery.croiz...@gmail.com> wrote:
> On 7 mar, 10:00, sfsf <s...@granit.de> wrote:
>
> > it is better to write our own cli compiler/interpreter or should we
> > use nemerle and
> > rewrite our code??? what is better ???
>
> If you use Nemerle :
> - you immediatly get many features listed in your previous post,
> notably a mature functional language, but not all of them.
> - Nemerle has a somewhat C#ish synbtax, but you can add most of the
> desired syntax features (if then else, begin end, etc.) with macros
> (seehttp://nemerle.org/Macros_tutorial)

VladD2

unread,
Mar 7, 2008, 8:49:04 AM3/7/08
to nemer...@googlegroups.com
2008/3/7, sfsf <s...@granit.de>:

> 1. first execution seconds ??? ... for example "c=a+b" or "c=a
> +b*func()" all
> of this variables and functions in current context -- i think like
> eval() function.

Yes, second[s], if it will be compiled on demand and don't use cache
of assemblies.
But I not understand why need 'string expression' evaluation.

> 2. it is better to write our own cli compiler/interpreter or should we
> use nemerle and
> rewrite our code??? what is better ???

The best way (in my opinion) use Nemerle itself (it syntax).
Of course, create compiler is very difficult. Nemerle developed more
than 5 years.
Interpreter you already have...

VladD2

unread,
Mar 7, 2008, 8:55:07 AM3/7/08
to nemer...@googlegroups.com
2008/3/7, sfsf <s...@granit.de>:

You can write simple class (wrappers) for array and string. All what
you need - modify indexer in it classes. Also you can define extension
methods which shift index, but it not right way.

VladD2

unread,
Mar 7, 2008, 9:17:53 AM3/7/08
to nemer...@googlegroups.com
2008/3/7, sfsf <s...@granit.de>:

> but why we must write
>
> return : {
> return(...);
> }
>
> the same in break continue. can you tell me an easier way or no
> way ???

You not need use blocks for return value. Last value of
function/method is it return value. Wellcom into functional world!


static Main (argv : array [string]) : int
{
def app = QApplication(argv);
def button1 = QPushButton("Hello World!");
button1.Resize(100,30);
button1.Show();

QApplication.Exec(); // It's work
}

Also you can open Nemerle.Imperative namespase and use imperative
operators like return/break/continue:
...
usung Nemerle.Imperative;

module Program
{


static Main (argv : array [string]) : int
{

when (someCondition())
return 0; // it's work

def app = QApplication(argv);
def button1 = QPushButton("Hello World!");
button1.Resize(100,30);
button1.Show();

QApplication.Exec(); // It's work
}

sfsf

unread,
Mar 7, 2008, 9:21:41 AM3/7/08
to Nemerle Forum
hallo,
we have dynamic assemblies (like doors, windows,...). the user can
write multiple parts.
in each part he can define len, depth, height of the part. for example
the len can expression of len=assembly_height-100+50 or the user can
build a if (...) len=200 else len=100 and so on

example:

# Abfragen welche Stiele gesetzt werden sollen
[IfStiel]
# Abfragen ob linker Stiel gesetzt werden soll
BERECH=((GetObjektAbst("LINKS","F",strrest(sBtWandName,3)+"*bta",
0,"")>=rBtTragStielBreite)&&(rBtWandAbstLi>rBtTrag
StielBreite+rBtStielBreite))?SetVarZ("StielLinksWandende",1)
BERECH=GetObjektAbst("LINKS","S","*.umr",ATT_BT_VARIANTE,"itu_w?
n")>=2*rBtTragStielBreite?SetVarZ("StielLinksTuerN",1)
BERECH=GetObjektAbst("LINKS","S","*.umr",ATT_BT_VARIANTE,"itu_w?
t")>=2*rBtTragStielBreite+rBtStielBreite?SetVarZ("StielLinksTuerT",1)
BERECH=GetVarZ("StielLinksWandende")==1&&GetVarZ("StielLinksTuerN")==1&&GetVarZ("StielLinksTuerT")==1?
SetVarZ("StielLinks",1)
# Abfragen ob rechter Stiel gesetzt werden soll
BERECH=((GetObjektAbst("RECHTS","F",strrest(sBtWandName,3)+"*bta",
0,"")>=rBtTragStielBreite)&&(rBtWandAbstRe>rBtTragStielBreite
+rBtStielBreite))?SetVarZ("StielRechtsWandende",1)
BERECH=GetObjektAbst("RECHTS","S","*.umr",ATT_BT_VARIANTE,"itu_w?
n")>=2*rBtTragStielBreite?SetVarZ("StielRechtsTuerN",1)
BERECH=GetObjektAbst("RECHTS","S","*.umr",ATT_BT_VARIANTE,"itu_w?
t")>=2*rBtTragStielBreite+rBtStielBreite?SetVarZ("StielRechtsTuerT",1)
BERECH=GetVarZ("StielRechtsWandende")==1&&GetVarZ("StielRechtsTuerN")==1&&GetVarZ("StielRechtsTuerT")==1?
SetVarZ("StielRechts",1)
# Abfrage ob unterer Querriegel gesetzt werden soll
BERECH=GetAttribZ(ATT_BT_OFSUNTEN)>0?SetVarZ("QuerriegelUnten",1)
# Variable fuer oberen Querriegel (wird immer gesetzt)
BERECH=SetVarZ("QuerriegelOben",1)
GOTO="IncludeStiele"

[IncludeStiele]
BERECH=BtInclude("wa_stiele.scc","Umriss")
BERECH=GetVarS("BauteilArt")=="Heizungsverteiler"?
BtInclude("konstanten.scc","Innentuer")
BERECH=GetVarS("BauteilArt")=="Heizungsverteiler"?
BtInclude("itu_ugbool.scc","Umriss")
GOTO="IfFraesSpl"

sfsf

unread,
Mar 7, 2008, 9:25:39 AM3/7/08
to Nemerle Forum
hallo,
oh .. thats great info .. thanks

VladD2

unread,
Mar 7, 2008, 9:56:15 AM3/7/08
to nemer...@googlegroups.com
2008/3/7, sfsf <s...@granit.de>:

>
> hallo,
> we have dynamic assemblies (like doors, windows,...). the user can
> write multiple parts.
> in each part he can define len, depth, height of the part. for example
> the len can expression of len=assembly_height-100+50 or the user can
> build a if (...) len=200 else len=100 and so on

And what a problem?

sfsf

unread,
Mar 10, 2008, 3:49:02 AM3/10/08
to Nemerle Forum
hallo,
"And what a problem? " ... i do not understand !! Is this a
question ???
but what you mean???

VladD2

unread,
Mar 11, 2008, 2:12:57 AM3/11/08
to nemer...@googlegroups.com
2008/3/10, sfsf <s...@granit.de>:

> "And what a problem? " ... i do not understand !! Is this a
> question ???
> but what you mean???

Why you need eval string expression in script?

sfsf

unread,
Mar 11, 2008, 3:53:30 AM3/11/08
to Nemerle Forum
hallo,
the expressions came from file and this files will be write by the
user. i do not know what the
user is writing. the users can use variables and functions they know
( they know not all functions or variable only special onces). the
user can change the contents of the file each time he start the script
which work with the file. the file is not a complete script only a
part of the script where the user can change and the script gives a
frame.

file.txt
--------------------------------------------
[rectangle]
BERECH=a=100;b=200
BERECH=a=300;b=500
BERECH=a=100*sin(45)*45;b=500/2*7

script.mak
---------------------------------------------

program;
var
int a,b;
int ii,iCount,iRet;
string sSccFile = "file.txt";
string arLst[100];
begin
iCount = GET_OPT_FILE(sSccFile,"rectangle",*arLst);
for(ii=1;ii<=iCount;ii++)
begin
iRet = berstr(arLst[ii]);
RECHT_2PKT(@(0,0),@(a,b));
end;
end.

Our Script/Interpreter is called Makro and is more an interpreter. i
hope you understand.
Reply all
Reply to author
Forward
0 new messages