Re: [q-lang-users] where
Brought to you by:
agraef
From: Rob H. <hub...@gm...> - 2006-10-09 13:32:52
|
Perhaps the "where" (and even "if" for a common conditional) keywords could be used for the "letting" clauses (assuming the grammar doesn't then become ambiguous, and assuming the language can be extended consistently in this way). Rob. On 09/10/06, Eddie Rucker <ed...@bm...> wrote: > Thanks Dr. Greaf for giving the reason. I will use case, cond, if then > else constructs for these situations. > > I understand that language decisions can be difficult. Would using a > "letting" statement as in the following example be bad or ugly? I'm > starting to be a bit curious about language design but I don't want to > waste much of your time on this. > > example: > > strip C "" = ""; > strip C S letting N = #S-1 > = strip C $ sub S 0 (N-1) if (S!N = C); > = strip C $ sub S 1 N if (S!0 = C); > = S otherwise; > > Eddie > > Eddie Rucker wrote: > > Given the following script > > > > // strip character C from the left and right sides of a string > > strip C "" = ""; > > strip C S = strip C $ sub S 0 (N-1) if (S!N = C) where N = #S-1; > > = strip C $ sub S 1 N if (S!0 = C) where N = #S-1; > > = S otherwise; > > > > Is it possible to have another type of local variable defined > at the end > > of a list of equations that would apply to all of them? > > No. I actually thought about this problem before. As local > variables are > maintained on the expression stack, it probably wouldn't be that > difficult to modify the VM to handle such shared qualifiers (as > long as > they share the same left-hand side). But I haven't been able to > come up > with a good syntax to support that in the language. > > So the solution is indeed to use case or if-then-else in such > situations > instead. > > Albert > > -- > Dr. Albert Gr"af > Dept. of Music-Informatics, University of Mainz, Germany > Email: Dr....@t-..., ag...@mu... > WWW: http://www.musikinformatik.uni-mainz.de/ag > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > q-lang-users mailing list > q-l...@li... > https://lists.sourceforge.net/lists/listinfo/q-lang-users > |