Page 1 of 1 1
Topic Options
#81222 - 2002-09-06 04:04 PM RFI: '.' dots in variable names
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Request for Implementation:

As stated in the manual, variables cannot contain a period '.', however, the period is valid for function names. This leads to an inconsistency since it is valid to create a function Class.Function() and call this function from KiXtart. However, this function cannot return a result since the variable $Class.Function is not a valid variable name.

I therefore propose to allow the period as part of a variable name in order to facilitate pseudo-object-oriented functions.

Alternatively, if it is impossible to implement, the functions names must not be allowed to contain periods in order to achieve naming consistency.

Desired implementation:
code:
$hours=Time.GetHours(@TIME)

function Time.GetHours($time)
Dim $splittime

$splittime = split($time,':')

$Time.GetHours = $splittime[0]
endfunction

This implementation would also enable KiXtart to support some kind of CLASS structure further down the development road, e.g. mimicking the Visual Basic class structures.

[ 06. September 2002, 16:05: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#81223 - 2002-09-06 04:17 PM Re: RFI: '.' dots in variable names
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
If .'s are allowed as variable names, then how would KiX be able to interpret a class call versus a variable call?

Something as simple as...
code:
$FORM.CAPTION = "My Title"

...may get broken.

Top
#81224 - 2002-09-06 04:25 PM Re: RFI: '.' dots in variable names
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
da,
I'd take a way of changing the returning procedure.

instead of the function-name use:
return $splittime[0]
endfunction

the class thing is anyway something I would like to see more...

to have class-library (example time) which has functions (gethours) inside it and could be called time.gethours...
_________________________
!

download KiXnet

Top
#81225 - 2002-09-06 04:36 PM Re: RFI: '.' dots in variable names
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
My vote - drop support for periods in function names (fix the inconsistency) ... but allow support for "functions-within-functions" ... imho - this would go a long way in furthering the OO cause.

Maybe with a structure like this (just green-lighting here):

code:
 
class Adder(constructor $parms...)


dim $n1,$n2


function SetN1($n)

$n1 = $n

endfunction


function SetN2($n)

$n2 = $n

endfunction


function Add()

$Add = $n1 + $n2

endfunction

endclass

then you could instantiate and use the object, just like a COM object. The periods in function names would now refer to a function within the class.

code:
$Adder = Adder()

$Adder.SetN1(2)
$Adder.SetN2(2)

$Answer = $Adder.Add()

one can always create functions to set and get (mimmic) properties (SetN1/GetN1) ... thats how things normally work under the covers anyways (in COM) ...

[ 06. September 2002, 16:48: Message edited by: Shawn ]

Top
#81226 - 2002-09-06 04:39 PM Re: RFI: '.' dots in variable names
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so, if we get class'es, why don't implement also private?
_________________________
!

download KiXnet

Top
#81227 - 2002-09-06 04:43 PM Re: RFI: '.' dots in variable names
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Anything DIMMED within the class would, by default, be private. Like $n1 and $n2 in the example above. Not accessible outside the class ... only through subfunction calls ... reall OO-like ..
Top
#81228 - 2002-09-06 04:55 PM Re: RFI: '.' dots in variable names
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
eh, what the heck eh ? never hurts to dream and conceptualize eh ?
Top
#81229 - 2002-09-06 06:42 PM Re: RFI: '.' dots in variable names
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
So, then ByVar and ByRef is already being worked on by Ruud? That should be part of it, too.

However, I do think that KiXtart can be intelligent enough to realize that e.g. $form.caption sets a value in the form object but that $time.gethour is a function call.
_________________________
There are two types of vessels, submarines and targets.

Top
#81230 - 2002-09-06 06:54 PM Re: RFI: '.' dots in variable names
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I thought about that too.
but if kix is to have classes, I rather take the sub-funcs as "." than "::" or something...

comma and dot have already partial reserved status so why not implement it in whole scale...

what comes to your first suggestion, I think it was flamed out by heavier posters in behalf of the "class" definition. [Razz]

I don't say your suggestion is bad, it is expected actually...
what I'm saying is that it should not be implemented before ruud says no to classes.
 
_________________________
!

download KiXnet

Top
#81231 - 2002-09-06 07:18 PM Re: RFI: '.' dots in variable names
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Agreed, this is Ruud's call ... my motto has always been "In Ruud We Trust" (really) ... there is a disrepency here - and how it plays-out is ultimately up to him.

But (my two cents) I would imagine that if Ruud was to ever OO-fy Kixtart ... he would probably want to reserve the period for OO purposes. Plus, he seems to have a bent toward keeping the syntax compatible with industry standards ... is the "period" an allowable character in other languages ? A quick test reveals that VBS does not allow this. I can't ever recall seeing anyone post or want to use, $variables that had periods in them.

My vote, keep compatible with other langauges and drop support of periods in varnames AND funcs ! Reserve periods for the future ... if there is no OO future for Kixtart ... then keep them in ... makes no diff then.

[ 06. September 2002, 19:22: Message edited by: Shawn ]

Top
#81232 - 2002-09-06 08:11 PM Re: RFI: '.' dots in variable names
kholm Offline
Korg Regular
*****

Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
Suggestion(s), add's to the brainstorming [Wink]

How about continnuing to let the the '.' be allowed in function names, and let the functions reference its returnvalue as the part after the '.' ?

Function name: Time.GetHours
Internal reference: $GetHours

Jens's example could then look like this:
code:
$hours=Time.GetHours(@TIME)

function Time.GetHours($time)
Dim $splittime
$splittime = split($time,':')
$GetHours = $splittime[0]
endfunction

If this was allowed and all scripts was following this syntax when dealing with a 'class' it might be easier to read other peoples scripts.

But this is just cosmetic, you migth as well make your own function name convention, like: All function names starting with $tm has to do with time, the script would then be:
code:
$hours=tmGetHours(@TIME)

function tmGetHours($time)
Dim $splittime
$splittime = split($time,':')
$tmGetHours = $splittime[0]
endfunction

This would work with the current version of KiX

- A second suggestion could be to let the function reference itself as me (new reserved word), the function could then be coded as:
code:
$hours=tmGetHours(@TIME)

function tmGetHours($time)
Dim $splittime
$splittime = split($time,':')
me = $splittime[0]
endfunction

function name would then be irrelevant, ofcourse KiX should still support $FunctionName as internal reference.

-Erik

ps.
I like the idea of allowing functions inside functions, sort of a function only 'alive' when the parrent is active.
What about functions inside functions inside functions .................. [Eek!]

Top
#81233 - 2002-09-06 08:15 PM Re: RFI: '.' dots in variable names
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Yes, and if you then rename the parent FUNCTION-ENDFUNCTION that encapsulates functions into class, you end up with classes CLASS-ENDCLASS [Smile]

So, either way, we're gyrating towards OOKiXtart [Big Grin]
_________________________
There are two types of vessels, submarines and targets.

Top
#81234 - 2002-09-06 08:19 PM Re: RFI: '.' dots in variable names
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
If I would define a function within a function (or Class), Then why couldn't I refer to variables as $Class.Varname even if not currently in the parent function/class definition?

Further more I may have a Date function/class library with various discreet date functions. Shouldn't I be able to Date.DayOfWeek(@date) for example?
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#81235 - 2002-09-06 08:37 PM Re: RFI: '.' dots in variable names
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
but isn't that different...

I migth be too a... drunk with pepsi but it then is not anymore variable name.

as if you reference:
$var.iable

$var would be the function and iable subfunction or variable name in it... struct or something...
_________________________
!

download KiXnet

Top
#81236 - 2002-09-06 08:42 PM Re: RFI: '.' dots in variable names
kholm Offline
Korg Regular
*****

Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
Howard,

Are you adding a request for static vars ?
Or is this already imlpied in this post ?

Top
#81237 - 2002-09-06 09:58 PM Re: RFI: '.' dots in variable names
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I guess I'm a little confused. I made a similar request/comment in another thread ( Should UDF collections be allowed) which is where I thought this "." in variables started.

I think that if a function within a class or package executes that we should be able to have persistent variables of the Class or package which could be referenced as $Class.var1 or $Package.Var1.

I haven't had much time lately to read all the post in depth (paycheck type work). Is this not what is being discussed?
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#81238 - 2002-09-06 10:31 PM Re: RFI: '.' dots in variable names
kholm Offline
Korg Regular
*****

Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
YES, Almost same discussion as in: Should UDF collections be allowed

AND almost the same partisipants.

Maybe we should summarize these discussions to a post in the suggestions (wish) forum ?

Like Shawn says: It never hurts to dream wha ? (wha ? being the danish version of eh ? in this situation) [Wink]

Top
#81239 - 2002-09-06 11:03 PM Re: RFI: '.' dots in variable names
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Erik: We ARE in the Suggestions forum. That is why I initiated this thread over here and labeled it as an RFI [Wink]
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Lonkero, ShaneEP, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 132 anonymous users online.
Newest Members
MaikSimon, kvn317, kixtarts2025, SERoyalty, mytar
17872 Registered Users

Generated in 0.069 seconds in which 0.023 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org