Scolring - Forum

Entraides et échanges autour de la technologie Scol - Informations and exchanges on the Scol technology

Vous pouvez changer la langue de l'interface une fois inscrit - You can change the language once registered

You are not logged in.

#1 26-Nov-2015 00:10:20

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,543
Website

strange (or stupid) typing error

hello

for the following code:

//variable to keep track of total created cylinders
var Cylinder_counter = 0;;
//variable to keep track of empties cylinders
var Emptied_Cylinders =0;;


struct   Cylinder =[
	Fradius			: F,
	Fheight			: F,
	funreturnheightasintergerasstring: fun[Cylinder] S,
	funreturnarea	:	fun [Cylinder] F,
	funreturnvolume:	fun[Cylinder] F
	
	]mkCylinder;;
	
typeof Cylinderlist = [[I Cylinder]r1];;
typeof Deleted_Cylinder_list =[I r1];;	
fun returnheight(dcylinder)=
	let ftoi dcylinder.Fheight -> height in
itoa height;;
	
fun killcylinder (trm, param)=
	let param -> [dcylinderindex dcylinder] in
	(
	//empty cylinder of all its values, it is now empty and its index is added to the Deleted_Cylinder_list
	set dcylinder.Fradius=nil;
	set dcylinder.Fheight=nil;
	set dcylinder.funreturnheightasintergerasstring=nil;
	set dcylinder.funreturnarea=nil;
	set dcylinder.funreturnvolume=nil;
	set dcylinder=nil;
	set Deleted_Cylinder_list = dcylinderindex::Deleted_Cylinder_list;
	_fooS strcatn "Just killed a cylinder with index: "::(itoa dcylinderindex):: nil;

	);
	0;;
	
	

fun return_area_function(dyclinder)=
	let dyclinder.Fradius *. PIf-> result in
	 result;;

fun return_volune_function(dyclinder)=
	let return_area_function dyclinder-> area in
	area *. dyclinder.Fheight;;
	 
fun initcylinder(radius, height, returnheightfunction, returnareafunction, returnvolumefunction)=
	_fooS "initializing cylinder";
	mkCylinder [radius height returnheightfunction returnareafunction returnvolumefunction];;



fun see_if_we_can_make_a_new_cylinder (deletedcylinderslist, radius, height) =
	if ((sizelist deletedcylinderslist)==0) then
	(
		_fooS "sorry, there are a maximum number of cylinders and none are free to assign new values to";
		0;
	)
	else
	(
		//get an index from the Deleted_Cylinder_list and fill it with new values, search Deleted_Cylinder_list recursively
	if ((hd deletedcylinderslist) != nil) then
		(
			//fill a deleted cylinder with new values and put the values in the Cylinderlist
			let initcylinder radius height @returnheight @return_area_function @return_volune_function -> lcylinder in
			let hd deletedcylinderslist -> cylinderindex in
			let switch cylinderindex Cylinderlist -> cylinder_to_change in
			set cylinder_to_change =lcylinder;
			_fooS "cylinder filled with new values.";
			0;
		)
		else
		(
			see_if_we_can_make_a_new_cylinder (tl deletedcylinderslist) radius height;
			0;
		);
	0;
	);
	0;;
	

fun makenewcylinder2(dfradius,dfheight )=
	//first check if Cylinderlist is full. If it's full, then we will have to see if there are any empty cylinders in the  Deleted_Cylinder_list
	//that we can fill with new values
	//I set an arbitrary nubmer of 1000 cylinders
	if ((sizelist Cylinderlist)>1001) then

	(
	
	//the list is full, find out if there are any cylinders in the deleted cylinder list that can be assigned new values
	see_if_we_can_make_a_new_cylinder Deleted_Cylinder_list dfradius dfheight;
	0;
	)
	else
	(
	//the Cylinderlist is not full, so we can add a new cylinder and index to the head of the Cylinderlist
	let initcylinder dfradius dfheight @returnheight @return_area_function @return_volune_function -> lcylinder in
	let ((sizelist Cylinderlist)-1)-> lcylinderlistsize in
	let [lcylinderlistsize lcylinder] -> cylinderparamter in
	(
	set Cylinderlist = [lcylinderlistsize lcylinder]:: Cylinderlist;
	_rfltimer _starttimer _channel 2500 @killcylinder cylinderparamter;
	);
	0;
	);
	0;;	
	
	
	


fun main()=
	_showconsole;
	set Deleted_Cylinder_list = nil;
	_fooS "the code up to now has compiled OK!";
	let 2000 -> counter in
	(
	while (counter > 0)do
	(

	makenewcylinder2 1.0 12.0;
	set counter = counter-1;
		
	);
	);
	
	
	0;;
	
	
 

I get a typing error at this line:

see_if_we_can_make_a_new_cylinder Deleted_Cylinder_list dfradius dfheight;

even though the global variable  Deleted_Cylinder_list is of the type [I r1], the vm shows the following typing error for the line directly above:

line 455 in ..\..\..\..\..\vm\kernel5\src\compiler\typmisc.cpp
File : C:\Users\Damiel Green\Documents\OpenSpace3D\customobjectfunctions\cylinderobjectlist.pkg
(!) Line #92:
	see_if_we_can_make_a_new_cylinder Deleted_Cylinder_list dfradius dfheight??;
>>> ERROR - Type mismatch (detail):
Found:    [[I r1] u0 u1]
Expected: [[[[[[I Cylinder] r1] Cylinder] r1] r1] F F]

I don't know why the vm thinks that see_if_we_can_make_a_new_cylinder  is not taking the correct argument of [I r1] and instead is expecting it to take  [[[[[[I Cylinder] r1] Cylinder] r1] r1] F F]...maybe it's a bug in the kernel, although it's probably me...

Offline

#2 26-Nov-2015 02:19:07

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,161
Website

Re: strange (or stupid) typing error

let hd deletedcylinderslist -> cylinderindex in
let switch cylinderindex Cylinderlist -> cylinder_to_change in

you inverted the list and the index in

let switch Cylinderlist cylinderindex -> cylinder_to_change in

so the runtime type checking think this first param must be a list so it define automatically the type for this argument as a list for future use.
This is why the error come after when you try to use this argument with a different type

Offline

#3 26-Nov-2015 03:33:26

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,543
Website

Re: strange (or stupid) typing error

Aahhh! Or Ack! Thx Arkeon! I thought it would be more likely to be a stupid error, though it looked so strange...

Last edited by hebdemnobad (26-Nov-2015 03:34:21)

Offline

#4 26-Nov-2015 17:32:34

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: strange (or stupid) typing error

I should really improve these errors. This is not explicit.

Offline

#5 26-Nov-2015 17:55:26

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,543
Website

Re: strange (or stupid) typing error

arkeon's  suggestion fixed things...but from your other post there is a more elegant way of going about this

Offline

#6 26-Nov-2015 19:17:50

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: strange (or stupid) typing error

Yes but the error messages can be obvious ...
The debugger is a hard job but it would be good to have it finally!
Currently, i have some problems with Windows and CMake ....

Offline

#7 27-Nov-2015 00:30:45

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,161
Website

Re: strange (or stupid) typing error

maybe that making a thread about build (cmake and other) should be a good idea smile
what is your current issue ?

Offline

Board footer

Powered by FluxBB